IOException 2?

I’m getting an IOException #2 on this line. I can’t even step into the function. What is an IOException #2?

if ioSaveFile(mFile.Data, "temp", CStr(Session.userID) + "_" + mFile.Name, True) then ....
Private mFile As WebUploadedFile
Function ioSaveFile(fData As MemoryBlock, fileDir As String, fileName As String, Optional deleteExisting As Boolean) As Boolean ....

perhaps if you provided the code of the function it self.

but I’d guess you are most likely creating a folderitem that is invalid, (based on your specification of “temp”)

The IOException page has links to places to find out IO Error codes for your OS.

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

end if

Return False
End Function
[/code]

Error Code 2 - No such file or directory

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

BTW - Where did you find this?