Translate Between Short and Long Paths

It is sometimes necessary to convert between short and long paths.
For example, in Win95/98, if the Path environment variable string
exceeds 1024 bytes, the string gets truncated. Or, some apps do
not accept long path names with spaces and short path names are
required.

I wrote a simple dialog-based app that takes a path string as an
input and produces the short and the long path names as an output.
Nothing fancy here. Just plain vanilla code that might prove
useful to someone.

For example entering:
C:Program Filesutilvslickwin;C:Program FilesMicrosoft Visual
StudioCommonToolsWinNT;C:Program FilesMicrosoft Visual
StudioCommonMSDev98Bin;C:Program FilesMicrosoft Visual
StudioCommonTools;C:Program FilesMicrosoft Visual
StudioVC98bin;C:PROGRA~1STINGR~1OE104lib;C:PROGRA~1STINGR~1Common
COMMON~1.01lib;C:PROGRA~1STINGR~1CommonMVC6~1.01lib;C:PROGRA~1STING
R~1OT601lib

produces the long path as follows:
C:Program Filesutilvslickwin;C:Program FilesMicrosoft Visual
StudioCommonToolsWinNT;C:Program FilesMicrosoft Visual
StudioCommonMSDev98Bin;C:Program FilesMicrosoft Visual
StudioCommonTools;C:Program FilesMicrosoft Visual
StudioVC98Bin;C:Program FilesStingray Objective
StudioOE104Lib;C:Program FilesStingray Objective StudioCommonCommon
6.01lib;C:Program FilesStingray Objective StudioCommonMVC
6.01lib;C:Program FilesStingray Objective StudioOT601lib

and the short path as follows:
C:PROGRA~1utilvslickwin;C:PROGRA~1MICROS~2CommonToolsWinNT;C:PROG
RA~1MICROS~2CommonMSDev98Bin;C:PROGRA~1MICROS~2CommonTools;C:PROGR
A~1MICROS~2VC98bin;C:PROGRA~1STINGR~1OE104lib;C:PROGRA~1STINGR~1C
ommonCOMMON~1.01lib;C:PROGRA~1STINGR~1OT601lib;q:ntutil;q:util;c:t
ools;q:es3rdpartywindows;q:esdev

Download demo project – 14 KB

Download demo application (sans source) – 8 KB

Date Last Updated: May 17, 1999

More by Author

Must Read