Quantcast
Channel: Flexera Software KB Articles
Viewing all articles
Browse latest Browse all 454

Q204745: CODE: Converting a Long Path to a Short Path on Windows

$
0
0

This article provides sample code demonstrating how to convert Windows long paths from the Choose Install Folder Panel and the Choose Folder Panel to a Windows short path. First, private String variables are declared to store the long paths and the short paths after the conversions. Then, the two long path class variables are initialized to the values of the InstallAnywhere variables containing the paths from the Choose Install Folder Panel and the Choose Folder panel using the substitute method of the InstallerProxy object to resolveeach InstallAnywhere variable. After getting a handle on the Win32Service, thegetShortPath methodis called by passing in the string variable containing the long path as a parameter. Lastly, the class prints to the console the values of the long paths and the short paths after the conversion.

Notes:
  • The sample code below does not perform error checking beyond printing the stack trace. Also, the sample code below requires that all of the directories in the long path exist before being converted into a short path.
  • Because the code uses the Win32Service, project option Project > Java > Add service support for custom code must be selected.

Viewing all articles
Browse latest Browse all 454

Trending Articles