Shellpath issues (Windows Only)

For Windows Shellpath supposes to return the Shortpath when the directory exists, otherwise it returns the Longpath

With a Longpath a lot of shell apps do not work correctly, even if you use quotes. So you ALWAYS need the Shortpath for those Shell apps.

[code]dim folder1,folder2 as FolderItem
folder1 = SpecialFolder.Desktop
msgbox folder1.ShellPath

folder2 =SpecialFolder.Desktop.child("test ")
MsgBox folder2.ShellPath
[/code]

You will notice folder1 will give the Shortpath (because it exists). folder1 will give the Longpath.

So, how can I get the Shortpath of folder2 ?

This is normal.

The short path is the result of the low level disk management that creates the Dos name in order to write to disk.

To obtain the short path, you must create the file :

[code] dim folder1,folder2 as FolderItem
folder1 = SpecialFolder.Desktop
system.DebugLog folder1.ShellPath

folder2 =SpecialFolder.Desktop.child("test “)
if not folder2.exists then
Dim t As TextOutputStream
t = TextOutputStream.Create(folder2)
t.Write(” ")
t.Close
end if
system.DebugLog folder2.ShellPath
[/code]

Thats a need trick. :slight_smile: Works fine.

BTW t.Write(" ") is not needed. :slight_smile: