gpt4 book ai didi

vb.net - vb.net 的 file.shortpath

转载 作者:行者123 更新时间:2023-12-01 10:59:17 25 4
gpt4 key购买 nike

我正在将我的项目从 vb6 转换为 vb.netvb.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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com