[.net] How to retrieve the short path form of a directory?
Is there a .NET way of acquiring the short path form, or do I need to import the function GetShortPathName?
Not quite sure what you mean by short path, but take a look at System.IO.FileSystem. It contains a number of methods to do path manipulation.
An example of long path is:
C:\Program Files
The short path equivalent is:
C:\Progra~1
It's the path name, constricted to 8 characters per directory, and with no spaces or other special chars.
I need it because one of the dll's I'm using for a project at work will not accept a directory name that is in long path form.
I've already imported GetShortPathName, but would rather just have a .NET equivalent. Having my code being partial Win32 & .NET will hurt compatibility and cause other problems later on imo.
C:\Program Files
The short path equivalent is:
C:\Progra~1
It's the path name, constricted to 8 characters per directory, and with no spaces or other special chars.
I need it because one of the dll's I'm using for a project at work will not accept a directory name that is in long path form.
I've already imported GetShortPathName, but would rather just have a .NET equivalent. Having my code being partial Win32 & .NET will hurt compatibility and cause other problems later on imo.
Well, first, I'd try passing the path name to the DLL in double quotes.
If that doesn't work, you'll have to use your GetShortPathName import. I couldn't find anything related to short names in System.IO.Path or any related namespace.
If that doesn't work, you'll have to use your GetShortPathName import. I couldn't find anything related to short names in System.IO.Path or any related namespace.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement