我正在将我的项目从 vb6 转换为 vb.net vb.net中有shortpath的模拟方法吗?
Dim DestinationFile As Scripting.File
...
DestinationFile.ShortPath
谢谢
最佳答案
不,现代语言不是为使用短路径而构建的,但您可以使用内核中的 GetShortPathName 方法:
Declare Auto Function GetShortPathName Lib "kernel32.dll" _
(ByVal lpszLongPath As String, ByVal lpszShortPath As StringBuilder, _
ByVal cchBuffer As Integer) As Integer
调用方式:
Dim name As String = "C:\Long Directory Name\Really really long filename.txt"
Dim sb As New StringBuilder(256)
GetShortPathName(name, sb, sb.capacity)
Dim shortName As String = sb.ToString()
关于vb.net - vb.net 的 file.shortpath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12727806/