开发者

How to find the root of a file

开发者 https://www.devze.com 2023-03-22 17:57 出处:网络
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

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

精彩评论

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

关注公众号