Live Chat Icon For mobile
Live Chat Icon

How can I convert a long path to a short path?

Platform: WinForms| Category: General IO

There is no direct support in the framework to do this. You have to use the GetShortPathName function using PInvoke.

This is how the signature for this function looks like:

[DllImport(''kernel32.dll'', SetLastError=true, CharSet=CharSet.Auto)]
    public  static extern int  GetShortPathName(string  longPath, [MarshalAs(UnmanagedType.LPTStr)]StringBuilder  ShortPath, [MarshalAs(UnmanagedType.U4)]int  bufferSize);

Download C# Sample
Download VB.NET sample

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.