Save selected Files(s) path

I need a way to save the folder for the path of the text file(s) a user selects.
In my program they are allowed to select any set of text files from any set of directories for later merging.
Since the merge can take some time, they are allowed to interrupt the process and resume later – hence the need to save the path for the selected files.

The output will be of their choosing as well, or perhaps by default to the first folder of the path of the first file they selected.

Suggestions?

Thanks in advance.

Ben

Use FolderItem.SaveInfo. That will store a type a string that will work like an alias that should work even if the user moves the original folder.

Dim f, savedFolder As FolderItem
f=GetOpenFolderItem("")
savedFolder = f.SaveInfo…

I don’t see it or I’m not doing it right. I have the following items as possible selections hitting tab after typing f.SaveInfo…

SaveInfoAbsoluteMode = 2
SaveInfoDefaultMode = 0
SaveInfoRelativeMode = 1

Are you targeting OS X, and want to ship your application on the Mac App Store? If you answer yes to both of these, you’re gonna need to learn about App Sandboxing. I’ve written a bunch of articles for xDev magazine on the App Sandbox.

I’ll dig out the links when, I can… One of them is here https://gumroad.com/l/pCSbL

Here’s what I’ve been doing for some time, but I just discovered that it doesn’t always work:

To save the path to a file (MyFolder) into a text file via TextOutputString:

dim fi as new FolderItem
dim SavedStr as string

if MyFolder<>nil then
SavedStr=MyFolder.GetSaveInfo(fi,0)
tos.WriteLine EncodeBase64(SavedStr)
end if

Then to get it back (where TempStr is the string I saved in the above code):

TempStr=DecodeBase64(TempStr)
MyFolder = GetFolderItem(TempStr)

However, when restoring it, if MyFolder<>nil going into it, then GetFolderItem doesn’t change it. Weird.

Hopefully someone smarter than me will show us how to really do it!

Strange how sometimes parallel concerns show up.

This sounds somewhat related to https://forum.xojo.com/29354-retaining-folderitem-for-file-on-external-drive

As it turns out, my code works just fine. I naively assumed that I was reading from the same file I had written to…

So Benjamin, give my code a try and see how it works for you. The only thing that’s slightly odd is you need the dim fi as FolderItem to give the GetSaveInfo a reference to work from.

[quote=241004:@John McKernon]As it turns out, my code works just fine. I naively assumed that I was reading from the same file I had written to…
[/quote]

John, I see a possible problem in your code.
You open a TextOutputStream and do a WriteLine with a Base64 encode string. This also insert an end of line char at the end, which changes depending on the platform.

Maybe this is not a problem but the SaveInfo information is binary, hence I suggest you to open a BinaryStream and directly write it without any Base64 encoding.