I have the following code that reads variables in the software and allows the user to save them into a text file.
Dim t As TextInputStream Dim f As FolderItem Dim dlg As OpenDialog dlg = New OpenDialog dlg.InitialDirectory=SpecialFolder.Userhome.Child("Dropbox") f = dlg.ShowModal() // open open dialog for selecting a file to load try if f<> nil then t = f.OpenAsTextFile // open selected text file // some code is here t.Close else //user cancelled end end try Return True
The code works as expected except of the situation when the user tries to save the file with the name of the existing file.
The OS tells me that a file with this name already exists, and asks if I want to override it. If I choose to override, it gives me an error.
The following line throws an exception error
t = f.OpenAsTextFile // open selected text file
I would appreciate any suggestion how to handle this situation better.
Thank you in advance,