I am trying to put a folder “MyApp” and a text-file into it without success… Thanks for help! It works until MsgBox “Check 0”… Also, would the solution be different for iOS?
try
dim f as FolderItem
dim addPrefFolderItem as FolderItem
dim dataStream as TextInputStream
dim resultData as string
dim addressePrefs as string
f = SpecialFolder.ApplicationData.child(“MyApp”).child(“MyAppTextFile”)
MsgBox “Check 0”
addressePrefs = addPrefFolderItem.NativePath
'read backup file
MsgBox “Check 1”
f = GetFolderItem(addressePrefs)
if f.Exists then
'File does exist
dataStream = f.OpenAsTextFile
resultData = dataStream.ReadAll()
dataStream.Close
if resultData = “” then
'No data
else
'Some data
end if
else
'File does not exist
end if
Catch error As RuntimeException
'do nothing
End Try
Thanks Kem, replaced the f=SpecialFolder… line with your code. Still it doesn’t make it past the next line
addressePrefs = addPrefFolderItem.NativePath
I basically copied and modified that “open file” code a while ago without proper understanding of the FolderItem story… It’s still a bit confusing…
try
dim f as FolderItem
dim addPrefFolderItem as FolderItem
dim dataStream as TextInputStream
dim resultData as string
dim addressePrefs as string
'f = SpecialFolder.ApplicationData.child(“MyApp”).child(“MyAppTextFile”)
f = SpecialFolder.ApplicationData.Child( “MyApp” )
if not f.Exists then
f.CreateAsFolder
end if
f = f.Child( “MyAppTextFile” )
MsgBox “Check 0”
addressePrefs = addPrefFolderItem.NativePath
'read backup file
MsgBox "Check 1"
f = GetFolderItem(addressePrefs)
if f.Exists then
'File does exist
dataStream = f.OpenAsTextFile
resultData = dataStream.ReadAll()
dataStream.Close
if resultData = "" then
'No data
else
'Some data
end if
else
'File does not exist
end if
Catch error As RuntimeException
'do nothing
End Try