Converting Windows file names to "short format"?
3 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Amos_Shapira
Posted On:   Wednesday, December 5, 2001 01:22 AM

Is there a way to obtain the "short filename" of windows files?


I mean, given a path like "C:Documents and SettingsamosLocal SettingsTemp" convert it to "C:DOCUME~1amosLOCALS~1Temp".


The point is that it seems that, at least with JDK 1.2 and 1.3, java.io fails to access files or folders with spaces in them.


Thanks.

Re: Converting Windows file names to "short format"?

Posted By:   Luigi_Viggiano  
Posted On:   Wednesday, December 5, 2001 03:23 PM

you shall use "\" instead of "" (it's a special 'escape' char) or use "/" instead. You can also obtain the File.separator and use it instead. This can be the problem...

Re: Converting Windows file names to "short format"?

Posted By:   Luigi_Viggiano  
Posted On:   Wednesday, December 5, 2001 03:21 PM

>The point is that it seems that,

>at least with JDK 1.2 and 1.3, java.io

>fails to access files or folders with

>spaces in them.


Check carefully the specified path.

File f = new File("C:/Documents and Settings/All Users/Menu Avvio/Windows Update.lnk");
System.out.println(f.getCanonicalPath());

it works...

Re: Converting Windows file names to "short format"?

Posted By:   Luigi_Viggiano  
Posted On:   Wednesday, December 5, 2001 03:13 PM

This is a OS dependant feature and you cannot get short name with Java. Anyway this is just a backward compatibility for DOS and Win16 apps, so you should not refer to files with short names.
About | Sitemap | Contact