Problem with folder item and path

Hi group, I have this problem. I would like to save an image by reading the Path from a file via a function ReadFileLineOfText(3), which returns a string read from a text file. Based on this I would like to set the path to “file” which is a FolderItem. I wanted to write file= ReadFileLineOfText(3) but of course it gives me an error.
P.S: The path in a file is C:\Users\test\OneDrive\Desktop\Image_TEST\

dim file as FolderItem 

if LeggiRigoFileDiTesto(3)=""  then
  file=SpecialFolder.Desktop.Child("test.jpg") 
  msgbox " Il File verrà salvato temporaneamente in " + file.NativePath + " Si consiglia di impostare una PATH nel file config."
else
  file=LeggiRigoFileDiTesto(3)+"test.jpg"
  msgbox " Il File verrà salvato in " + LeggiRigoFileDiTesto(3)+"test.jpg"
end if
DeviceManager.GetImageDialog(self, DeviceType, flags, intent, file, root)

file =Getfolderitem(LeggiRigoFileDiTesto(3)+"test.jpg")

or

file = new folderitem(LeggiRigoFileDiTesto(3)+"test.jpg", 3)

This relies on you saving a valid file path in your text file. (eg C:\somefolder\basename )

if you save a path or a filename that does not exist when you look next time, file will be nil
And I assume you are saving the file path as ‘native’ format, which is why the second parameter is a 3

Better imo to use the class constant.

file = new folderitem(LeggiRigoFileDiTesto(3)+"test.jpg", FolderItem.PathModes.Native)

2 Likes

Thanks Jeff, it wotk fine :slight_smile: :slight_smile:

Hi Julia, thanks !