ShortPath Name in C#

  • Thread starter Thread starter Usman
  • Start date Start date
U

Usman

Hi

Is there any way to get the short path name of the file or folder in C#.
Just like the API "GetShortPathName" in C++

Regards

Usman
 
Hello, Usman!

U> Is there any way to get the short path name of the file or folder in C#.
U> Just like the API "GetShortPathName" in C++

IIRC you will have to P/Invoke to get such functionality
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
Hello Vadym,

VS> Hello, Usman!
VS>
U>> Is there any way to get the short path name of the file or folder in
U>> C#. Just like the API "GetShortPathName" in C++
VS> IIRC you will have to P/Invoke to get such functionality

yep, here http://groups.google.de/group/microsoft.public.dotnet.languages.vb/msg/ebf01196a689c3af

VS> --
VS> Regards, Vadym Stetsyak
VS> www: http://vadmyst.blogspot.com
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
Hi

Any Idea how to call this in API in C#. The syntax in the example is for
VB.Net.

Regards

Usman
 
Hello, Usman!

I suppose it would look like this...

[System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "GetShortPathName", SetLastError = true)]
private static extern int PlaySound(string lpszLongPath , string lpszShortPath , int cchBuffer);

string strPath = Application.StartupPath;
string strShortPath = new string(' ', 100);
int n = GetShortPathName(strPath, strShortPath, 100) ;
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
Back
Top