开发者

How to find the root of a file

I am trying to find the folder that my file is in so I can use it else where. I am using an openfiledialog. So, if the pa开发者_StackOverflow社区th of the file is "C:\test\test.text". I want to be able to get "c:\test" without the file how would i do this?


 Dim path as String = System.IO.Path.GetDirectoryName(fileName)


If you have the whole path, you can use Path.GetDirectoryName:

Dim filePath As String = Path.GetDirectoryName("C:\test")

That would return C:

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜