RealBasic app crashes on writeline
I have an Mac RB app that crashes when I write a line to a TextOutputStream on the user's preferences. The write operation works great when the user is the admin, but any other user crashes. This made me think it's a permission issue, so I tried changing permission, without luck.
The error is: "An exception of class NilObjectException was not handled. The operation must shut down"
Any help from you amazing people would be greatly appreciated. Thanks!
Here's the code:
Dim TableString as String
Dim fileStream As TextOutputStream
Dim File as FolderItem
File = SpecialFolder.SharedPreferences.Child("FileName.txt")
TableString = TranslationTableToString
fileStream=File.CreateTextFile
// This didn't help:
//File.permissions= &o777
// This line Breaks:
fileStr开发者_开发知识库eam.WriteLine TableString
You don't mention what version of RB you are using, but for any reasonably current version, the syntax you should be using is:
fileStream = TextOutputStream.Create(File)
Which you should wrap in a Try/Catch to get this:
Try
fileStream = TextOutputStream.Create(File)
fileStream.WriteLine(TableString)
Catch e As IOException
MsgBox("Error Code: " + Str(e.ErrorNumber))
End Try
e.ErrorNumber will contain an OS-specific error code to help you pinpoint the problem.
http://docs.realsoftware.com/index.php/IOException
精彩评论