我用openfiledialog打开文件后,会生成一个存储前面所选取的文件路径的文件,然后我要把这个生成的文件放在openfiledialog所打开文件的上一级目录,这个路径(openfiledialog选取的文件的上一级目录)要怎么写

解决方案 »

  1.   

    就是我要获取一个路径,这个路径是openfiledialog打开的文件目录的上一级目录
      

  2.   

    System.IO.Path.GetDirectoryName(System.IO.Path.GetDirectoryName(openfiledialog.FileName))
      

  3.   

    System.IO.Path.GetDirectoryName("strPath");如何还要上级System.IO.Path.GetDirectoryName(System.IO.Path.GetDirectoryName("strPath"));
      

  4.   

    你的意思是获取父文件夹吧,参考:
    http://technet.microsoft.com/zh-cn/magazine/system.io.directoryinfo.parent.aspx
      

  5.   

    可以了,不好意思,后来有点事,不过就是这个了:
    System.IO.Path.GetDirectoryName(System.IO.Path.GetDirectoryName(openfiledialog.FileName))
    谢谢!