Use the following snippet to obtain the executing computer's temporary directory:
str dirTmp = (isRunningOnServer() ?
WinAPIServer::getTempPath() : WinAPI::getTempPath());
;
info(dirTmp); // 'C:\Docs and Stuff\JDoe\Local Config\Temp\'
However... We're actually doing a bit more work inside that
WinAPIServer::getTempPath() function as we're checking server-side for I/O access and dll interop permission so don't be surprised if you generate and error the first time you run it. Here's my call stack with the error:
Error en la solicitud de permiso de tipo 'FileIOPermission'.
(S)\Classes\FileIOPermission\demand
(S)\Classes\WinAPIServer\getTempPath - line 13
(S)\Classes\EVE_CONGenerateFile\saveLocalFile - line 7
(S)\Classes\EVE_CONGenerateFileProvisional\sendToHost - line 29
(S)\Classes\EVE_CONFileExporter\mainOnServer - line 31
(C)\Classes\EVE_CONFileExporter\main - line 4
(C)\Classes\MenuFunction\run
(C)\Classes\FormFunctionButtonControl\Clicked - line 16
The answer was in
this post, indicating that we now need to assert 'FileIOPermission' before calling
WinAPIServer::getTempPath()... Which personally feels
wrong to me. I added the following hack before the call:
FileIOPermission _permHACK = new FileIOPermission('','r');
str tempPath;
;
_permHACK.assert();
tempPath = (isRunningOnServer() ?
WinAPIServer::getTempPath() :WinAPI::getTempPath());
// revert previous assertion
CodeAccessPermission::revertAssert();
Later on in the code when obtaining read/write permission to the aforementioned temporary directory I was getting '
Varias llamadas a CodeAccessPermission.Assert/
Multiple calls to CodeAccessPermission.Assert' error so don't forget to add the last line above, and
revert our assertions before performing a second Assert. The alternative being to create a Set of these permission classes and
assert multiple times.
No hay comentarios:
Publicar un comentario