Hi,
I want to move files using RenameFile() from network share with virus scanner to local share. If the virus scanner catches the file, I want to know it (to give user information). But RenameFile() is only saying Yes or No.
But there are many possible reasons for failure. I need to know if it has been because of:
- ERROR_FILE_NOT_FOUND
- ERROR_ACCESS_DENIED
- ERROR_INVALID_DRIVE
- ERROR_NOT_READY
- ERROR_READ_FAULT
- ERROR_VIRUS_INFECTED
- ERROR_VIRUS_DELETED
Any idea how to get this return codes without the need to use API (cross plattform)? Something like GetLastIOError() function?
Kukulkan
How to find reason for failed RenameFile()?
Re: How to find reason for failed RenameFile()?
You can use the API function "GetLastError" with PB functions as they call the API (on windows), but i would use "MoveFile" if using API error checking .... just in case!!
that would take care of the windows part, cant help for other OS's, soz
Code: Select all
;result = RenameFile("||.ext", "nofile2.ext")
result = MoveFile_("||.ext", "nofile2.ext")
Buffer.s = Space(4096)
Chars.l = FormatMessage_(#FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError_(), 0, Buffer, Len(Buffer), 0)
Debug Left(Buffer, Chars-2)
Re: How to find reason for failed RenameFile()?
Thanks MicroByte. Yes, that might work on Windows. MoveFile API is possibly the best solution.
But what is the return value of PB good for? Wouldn't it be much better to return some generalized errors? Maybe the most common ones in a PB specific way?
Anyway, I'd be happy to find the equivalents of Move_ on Linux and Mac...
Best
Kukulkan
But what is the return value of PB good for? Wouldn't it be much better to return some generalized errors? Maybe the most common ones in a PB specific way?
Anyway, I'd be happy to find the equivalents of Move_ on Linux and Mac...
Best
Kukulkan