如何从 FileName
返回的路径中删除实际文件名打开或保存文件对话框的属性?
我想要的只是没有文件名的文件路径。
最佳答案
将完整路径(包括文件名的路径)传递给 System.IO.Path.GetDirectoryName
方法。这将去掉文件名并返回包含该文件的目录的完整路径。
例如:
Dim filePath As String = "C:\MyDir\MySubDir\myfile.ext"
Dim directoryPath As String = Path.GetDirectoryName(filePath)
将以下字符串放入
directoryPath
多变的:C:\MyDir\MySubDir
关于vb.net - 如何从 FileDialog.FileName 返回的路径中删除文件名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4895726/