Translate Between Short and Long Paths | CodeGuru

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 […]

Written By
CodeGuru Staff
CodeGuru Staff
May 17, 1999
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

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

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.