Click here to Skip to main content
16,004,727 members
Home / Discussions / C#
   

C#

 
GeneralRe: FileStream question Pin
Heath Stewart9-Dec-03 7:28
protectorHeath Stewart9-Dec-03 7:28 
GeneralRe: FileStream question Pin
Tim Kohler9-Dec-03 7:37
Tim Kohler9-Dec-03 7:37 
GeneralRe: FileStream question Pin
Tim Kohler10-Dec-03 3:54
Tim Kohler10-Dec-03 3:54 
GeneralCreating XML Documents Pin
MrEyes9-Dec-03 5:28
MrEyes9-Dec-03 5:28 
GeneralRe: Creating XML Documents Pin
MrEyes9-Dec-03 6:02
MrEyes9-Dec-03 6:02 
GeneralRe: Creating XML Documents Pin
Heath Stewart9-Dec-03 6:24
protectorHeath Stewart9-Dec-03 6:24 
Generallong path to short path Pin
elena123459-Dec-03 5:12
elena123459-Dec-03 5:12 
GeneralRe: long path to short path Pin
Heath Stewart9-Dec-03 6:20
protectorHeath Stewart9-Dec-03 6:20 
There is nothing in the .NET base class library that does this (at least nothing public that I can remember / find), but - if your app runs on Windows 2000 or higher (any NT-based system) - you can P/Invoke the function PathGetShortPath:
[DllImport("shell32.dll", CharSet=CharSet.Unicode)]
public static extern void PathGetShortPath(string path);
You pass the long path into the method and after it returns path contains the short path.

If you need something that works on all operating systems that .NET runs on, you'll have to enumerate each directory and the filename and change it to the 8.3 filename format. It's been a long time since I've worked with these, so you might want to check the PSDK to see if it documents how similarily named files or directories are resolved using the "~N" notation (like "MICROS~1", "MICROS~2", etc.).

You should also trying googling for the solution. I'm sure someone else has had to deal with this before.

 

-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
GeneralRe: long path to short path Pin
Stephane Rodriguez.9-Dec-03 21:24
Stephane Rodriguez.9-Dec-03 21:24 
GeneralNew to C# Question Pin
Larry J. Siddens9-Dec-03 4:07
Larry J. Siddens9-Dec-03 4:07 
GeneralRe: New to C# Question Pin
Colin Angus Mackay9-Dec-03 4:35
Colin Angus Mackay9-Dec-03 4:35 
GeneralRe: New to C# Question Pin
Heath Stewart9-Dec-03 6:10
protectorHeath Stewart9-Dec-03 6:10 
GeneralRe: New to C# Question Pin
Larry J. Siddens9-Dec-03 11:29
Larry J. Siddens9-Dec-03 11:29 
GeneralRe: New to C# Question Pin
Heath Stewart9-Dec-03 11:33
protectorHeath Stewart9-Dec-03 11:33 
GeneralRe: New to C# Question Pin
Huseyin Altindag9-Dec-03 10:57
Huseyin Altindag9-Dec-03 10:57 
GeneralFirst Call to Function does nothing: c# Pin
Goodspeed20029-Dec-03 3:50
Goodspeed20029-Dec-03 3:50 
GeneralRe: First Call to Function does nothing: c# Pin
Heath Stewart9-Dec-03 6:08
protectorHeath Stewart9-Dec-03 6:08 
GeneralRe: First Call to Function does nothing: c# Pin
Goodspeed20029-Dec-03 12:43
Goodspeed20029-Dec-03 12:43 
GeneralRe: First Call to Function does nothing: c# Pin
Heath Stewart9-Dec-03 14:13
protectorHeath Stewart9-Dec-03 14:13 
QuestionHow to validate regular expression pattern? Pin
gokselm9-Dec-03 3:30
gokselm9-Dec-03 3:30 
AnswerRe: How to validate regular expression pattern? Pin
Heath Stewart9-Dec-03 5:53
protectorHeath Stewart9-Dec-03 5:53 
GeneralRe: How to validate regular expression pattern? Pin
gokselm10-Dec-03 11:35
gokselm10-Dec-03 11:35 
GeneralChange Notification Pin
mkomasi9-Dec-03 2:50
mkomasi9-Dec-03 2:50 
GeneralRe: Change Notification Pin
Heath Stewart9-Dec-03 3:02
protectorHeath Stewart9-Dec-03 3:02 
GeneralFolder Permissions Pin
Mauricio Ritter9-Dec-03 2:50
Mauricio Ritter9-Dec-03 2:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.