Access Denied to a folder created by the script
4 ビュー (過去 30 日間)
古いコメントを表示
Hello Everyone-
I am not an expert on Matlab but I am trying to validate some theoritical results using it as an interface of OpenEMS. I keep getting an error of denied access to a folder created by the script itself. I have tried running Matlab as an Admin and deletingt he folder and renaming it and even changing directories. I am kind of stuck and confused about the reason behind this error. Please see part of the code below and error. Thank you very much!
this is the part of the code in which I create the fodler:
%% Path
Sim_Name = ['Sim_DOA_', num2str(a), 'deg']; % e.g., Sim_DOA_-60deg
Sim_Folder = fullfile('C:\Users\HP\Documents\MATLAB\Simulations', Sim_Name);
Sim_CSX = 'geometry.xml'; % geometry file name
% Create the folder if it doesn't exist
if ~exist(Sim_Folder, 'dir')
mkdir(Sim_Folder);
end
WriteOpenEMS(Sim_Folder, FDTD, CSX);
RunOpenEMS(Sim_Folder, Sim_CSX);
and this is the error:
Error using xmlwrite>xmlWriteHelper (line 152)
Java exception occurred:
java.io.FileNotFoundException: C:\Users\HP\Documents\MATLAB\Simulations\Sim_DOA_-60deg (Access is
denied)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
Error in xmlwrite (line 78)
xmlWriteHelper(result,source,varargin{1});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in struct_2_xml (line 11)
xmlwrite(xmlFileName,docNode);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in WriteOpenEMS (line 19)
struct_2_xml(filename,openEMS,'openEMS');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in OpenEMSDOAVALIDATION (line 85)
WriteOpenEMS(Sim_Folder, FDTD, CSX);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0 件のコメント
回答 (1 件)
Torsten
2025 年 8 月 21 日
編集済み: Torsten
2025 年 8 月 21 日
You create
C:\Users\HP\Documents\MATLAB\Simulations\Sim_DOA_-60deg
as a folder.
But
WriteOpenEMS(Sim_Folder, FDTD, CSX);
assumes that
C:\Users\HP\Documents\MATLAB\Simulations\Sim_DOA_-60deg
is a filename.
So you try to write to a folder instead of a file which gives an error.
At least that's what I suspect is the problem.
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!