vb.net的file.shortpath [英] file.shortpath for vb.net

查看:111
本文介绍了vb.net的file.shortpath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要把我的项目从vb6转换为vb.net
,在shortpath的vb.net中有模拟方法吗?

ho i'm converting a my project from vb6 to vb.net Is there an analog method in vb.net of shortpath?

Dim DestinationFile As Scripting.File
...
DestinationFile.ShortPath

谢谢

推荐答案

不,现代语言不是为使用短路径而构建的,但是您可以使用GetShortPathName内核中的方法:

No, modern languages are not built to use short paths, but you can use the GetShortPathName method from the kernel:

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的file.shortpath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆