I have looked at the NSError doc for Mac but they don’t list and error code 2.
App.DocumentRoot = “/Users/srich/Development/Projects/Developer Tools/files” which is successfully created on startup.
[code]Function ioSaveFile(fData As MemoryBlock, fileDir As String, fileName As String, Optional deleteExisting As Boolean) As Boolean
if fData.Size > 0 and Len(fileDir) > 0 and Len(fileName) > 0 then
Dim fDirPath As String = App.DocumentRoot + “/” + fileDir
Dim f, fDir As FolderItem
if ioFolderExists(fDirPath.ToText, True) then
fDir = GetFolderItem(fDirPath, FolderItem.PathTypeShell)
if fDir.Exists then
Dim output As BinaryStream
Try
' Save file
f = fDir.Child(fileName)
output = BinaryStream.Create(f, deleteExisting)
output.Write(fData)
output.Close
Return True
End Try
end if
end if
Thanks Dave. I was appending the DocumentRoot twice which (obviously) results in “No such file or directory”. The function now works without error so long as I leave the MemoryBlock out. As soon as I try to pass the MemoryBlock, I get the IOException 2 again. Why should passing a MemoryBlock have anything to do with an Error Code 2?
Works:
Function ioSaveFile(fileDir As String, fileName As String, Optional deleteExisting As Boolean) As Boolean
Doesn’t work:
Function ioSaveFile(fData As MemoryBlock, fileDir As String, fileName As String, Optional deleteExisting As Boolean) As Boolean