Get "short" path

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hi,

I use some old application that need "short path" - previous dos style.
For example , I need to convert "C:\MyLongPath\1.txt" to
"c:\mylong~1\1.txt". Does exist any classes at vb.net for doing this?
Thanks,
Michael
 
You can try the GetShortPathName API:

Declare Auto Function GetShortPathName Lib "kernel32.dll" _
(ByVal lpszLongPath As String, ByVal lpszShortPath As
StringBuilder, _
ByVal cchBuffer As Integer) As Integer

Call it like this:

Dim s As String = "c:\Long Dir Name\Longfilename.txt"
Dim sb As New StringBuilder(256)
GetShortPathName(s,sb,sb.capacity)

MsgBox(sb.ToString)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top