![]() |
#5 |
Боец
|
Держите корректную обработку, универсальную для клиентского и серверного исполнения + Batch. На этом постоянно приходилось спотыкаться.
X++: static boolean fileExists(FilePath _filePath) { boolean ret; ; if(isRunningOnServer()) { new FileIOPermission(_filePath, #io_read).assert(); //BP Deviation Documented ret = WinAPIServer::fileExists(_filePath); CodeAccessPermission::revertAssert(); } else { ret = WinAPI::fileExists(_filePath); } return ret; } X++: public static boolean moveFile(FilePath _filePathFrom, FilePath _filePathTo) { boolean ret; System.Exception ex; ; if (AXUtils::fileExists(_filePathFrom)) { if(isRunningOnServer()) { new InteropPermission(InteropKind::ClrInterop).assert(); try { System.IO.File::Move(_filePathFrom, _filePathTo); ret = true; } catch (Exception::CLRError) { ex = CLRInterop::getLastException(); error(ex.ToString()); } CodeAccessPermission::revertAssert(); } else { WinAPI::moveFile(_filePathFrom, _filePathTo); ret = true; } } else { info(StrFmt("File '%1' does not exist.", _filePathFrom)); } return ret; } X++: public static boolean deleteFile(FilePath _filePath) { boolean ret; ; if (AXUtils::fileExists(_filePath)) { if(isRunningOnServer()) { new FileIOPermission(_filePath, #io_write).assert(); //BP Deviation Documented ret = WinAPIServer::deleteFile(_filePath); CodeAccessPermission::revertAssert(); } else { ret = WinAPI::deleteFile(_filePath); } } else { ret = true; } return ret; } |
|
|
За это сообщение автора поблагодарили: AlexeyS (2), S.Kuskov (2), arhat (1). |
|
![]() |
||||
Тема | Ответов | |||
axaptapedia: WinAPI | 0 | |||
Dynamics AX Geek: Finding files with WinAPI | 1 | |||
Dynamics AX Geek: Finding files with WinAPI | 0 | |||
WinApi::deleteFile(filePath) | 3 | |||
WinApi. Удаление файлов глючит. | 10 |
|