필터 지우기
필터 지우기

"Access is denied." Error

조회 수: 14 (최근 30일)
Allen Hammack
Allen Hammack 2024년 5월 1일
답변: Prateekshya 2024년 5월 2일
I am running a script where I'm trying to create a directory if the directory doesn't already exist. The relevant section of my script
if exist(input_all_daily{1}.all_plots_location,'dir') == 0
mkdir(input_all_daily{1}.all_plots_location)
else
end
Sometimes, when I run this script, I get an "Access is denied." error that references the mkdir line. When I rerun the script without making any changes, the "Access is denied." is no longer generated. I have no idea what do to about this error. Can someone please help?

답변 (1개)

Prateekshya
Prateekshya 2024년 5월 2일
Hi Allen,
As per my understanding you are getting "Access is denied" error. Please execute the below:
Implement a "try-catch" block around your code to catch the error and display more information. This might give you more insight into why the error occurs.
try
if exist(input_all_daily{1}.all_plots_location,'dir') == 0
mkdir(input_all_daily{1}.all_plots_location)
end
catch ME
fprintf('Failed to create directory: %s\n', input_all_daily{1}.all_plots_location);
disp(getReport(ME));
end
This can help identify if the problem is consistently reproducible or if it provides any additional details on the error.
Please let me know if you have any further queries.
I hope this helps.
Thank you.

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by