Windows shellpaths

I’m getting data from Python via a file. Shellpaths work nicely on Mac OS and Linux. But Windows is confusing me. I get for instance a path like “C:\Users\BEATRI~1\AppData\Local\Temp\tmpvy9a5l57” from Windows (8.1).

In Xojo 2014r2.1 I have

dim MailFolderitem as FolderItem = GetFolderItem(theResult, FolderItem.PathTypeShell)

but the resulting folderitem doesn’t exist. I’ve verified in Windows Explorer that the file does exist. What am I missing here?

[quote=133744:@Beatrix Willius]I’m getting data from Python via a file. Shellpaths work nicely on Mac OS and Linux. But Windows is confusing me. I get for instance a path like “C:\Users\BEATRI~1\AppData\Local\Temp\tmpvy9a5l57” from Windows (8.1).

In Xojo 2014r2.1 I have

dim MailFolderitem as FolderItem = GetFolderItem(theResult, FolderItem.PathTypeShell)

but the resulting folderitem doesn’t exist. I’ve verified in Windows Explorer that the file does exist. What am I missing here?[/quote]

In Windows, you got in fact two kinds of shellpath : the Windows one, also called longpath, that is what you would type in the Command line or see on icons and in the window URL, and the path used internally by the system, which dates back to DOS, which did not support folder and file names longer than 8 characters. What you get is the Dos path, which for all intents and purposes, is the closest equivalent to the Mac escaped path, since it never contains spaces.

http://msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx#short_vs._long_names

The example you posted should work, though. I am going to do some tests in Windows and try to find out what is going on.

i suspect that if you have the drive (c:) in the string then you need to use absolutepath instaed of shellpath

Actually in Windows Absolute, Native and Shell are the same thing.

I just tried to create a file in temp inside a folder with a space in it, so I get the dos path, then do a GetFolderItem with the string, and it works with all three types. Xojo finds the file to exist in all cases.

Something else may be going on. Maybe the file reported by Python is not finished creating when you verify it exists ?

I see the problem now. Windows uses an EndOfLine that is 2 characters instead of 1 and I cut off only one character.

Thanks for your help!

Yes, EndOfLine.Windows is chr(13)+chr(10). Instead of trim, you can also replaceall(mystring, EndOfLineWindows,"")

Or use Trim().

Thanks Tim, that’s a good idea. Don’t know why I didn’t think of this.