-2
我似乎無法在Windows 10 64位的NAS分區上調用ForceDirectories()
。NAS ForceDirectories
我可以使用Windows資源管理器在NAS上創建一個文件夾就好了。
procedure TForm3.Button1Click(Sender: TObject);
var
tempDir: String;
begin
tempDir := 'z:\ttt\ttttest';
if NOT DirectoryExists(tempDir) then
if System.SysUtils.ForceDirectories(tempDir) then
ShowMessage('Dir: ' + tempDir + ' Forced alright')
else
ShowMessage('Dir: ' + tempDir + ' Force FAILED with error : '+ IntToStr(GetLastError));
end;
Z:
是西部數據的網絡附加存儲,其在所有其他方面正常工作。
該代碼每次都返回錯誤3。
相同的代碼在本地驅動器上正常工作。
適合我。可能是本地權限問題的映射。有人想知道你是否以管理員身份運行delphi ide。 –
此外,我相信你知道這裏的意思是什麼:https://msdn.microsoft.com/en-gb/library/windows/desktop/ms681382(v=vs.85).aspx –
錯誤3是'ERROR_PATH_NOT_FOUND'。驅動器盤符映射是針對每個用戶的,因此運行應用程序的用戶帳戶可能不存在'Z:'驅動器。另外,'ForceDirectories()'在創建目錄之前檢查目錄是否存在,所以你不需要手動調用'DirectoryExists()'。 –