vb.net - vb.net 的 file.shortpath

标签 vb.net file vb6 converter

我正在将我的项目从 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/

相关文章:

arrays - 使用 vb.net 替换数组中的文本

c - 从文件中读取一串信息并按int结果排序

c - 读取文件然后将数字存储在数组 C 中

.net - 实例化 .Net COM 可见类时出现自动化错误

vb.net - Web 浏览器单击没有 ID 或名称的按钮

mysql - 不确定如何处理 NullReferenceException

vb.net - VB.NET 中的 CInt(Long) 在 32 位和 64 位环境中表现不同

objective-c - 从 Xcode Bundle 读取文本文件

vb.net - 打包 vb6/vb.net 混合应用程序的最佳方法是什么?

vb6 - 如何处理 VB6 .vbp 文件引用更改