Access Denied to a folder created by the script
조회 수: 3 (최근 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!