2010-10-07 171 views
1

我有一個Mac RB應用程序在我根據用戶的偏好向TextOutputStream寫入一行時崩潰。 當用戶是管理員,但其他任何用戶崩潰時,寫入操作很好。 這讓我覺得這是一個權限問題,所以我試圖改變權限,沒有運氣。RealBasic應用程序在writeline上崩潰

的錯誤是: 「類NilObjectException的異常沒有被處理的操作必須關閉。」

您的任何幫助,讓人歎爲觀止將不勝感激。 謝謝!

下面的代碼:

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: 
fileStream.WriteLine TableString 

回答

1

你沒有提到你使用的是什麼版本的RB的,但對於任何合理的當前版本,您應該使用的語法是:

fileStream = TextOutputStream.Create(File) 

你應該在Try/Catch中包含以下內容:

Try 
    fileStream = TextOutputStream.Create(File) 
    fileStream.WriteLine(TableString) 
Catch e As IOException 
    MsgBox("Error Code: " + Str(e.ErrorNumber)) 
End Try 

e.ErrorNumber將包含一個OS-特定的錯誤代碼來幫助您查明問題。

http://docs.realsoftware.com/index.php/IOException

+0

謝謝!將盡快實施從假期返回:-) – 2010-10-14 01:21:41