getting error "error writing file name.m C:\program files\matlab\folder name\file name.m(access is denied) "

3 次查看(过去 30 天)
getting error stated in MATLAB editor window i.e. error writing file name.m C:\program files\matlab\folder name\file name.m(access is denied)
  4 个评论
Ade Aulya
Ade Aulya 2018-5-30
编辑:Walter Roberson 2018-5-30
hi, @hamidreza eslami
i really beg your pardon for this stupid question. i have tried as u said but i still got the same error.
like from here :
filePattern = fullfile('C:\Users\DataBaseBC\DATABC1\Train 50%', '*.tif');
tiffFiles = dir(filePattern);
to :
filePattern = fullfile('C:\Program Files\MATLAB\R2017a\DATABC1\Train 50%', '*.tif');
tiffFiles = dir(filePattern);
was it right ?
what should i do ?
Walter Roberson
Walter Roberson 2018-5-30
Ade Aulya,
The error message involved in this Question has to do with permission denied when attempting to write to a file. The code you show is only trying to see which files are in a directory, and would not itself try to write to any files. You might have another bit of code later that is trying to write to a file.
If you are trying to write to files in C:\Program Files\MATLAB\R2017a\DATABC1\Train 50% then that is not a good place to store the files. MS Windows does not permit users to write inside the Program Files directory.
On the other hand, the code you posted does not attempt to change directory and does not in itself pull out the directory name C:\Program Files\MATLAB\R2017a\DATABC1\Train 50% to write files to. It is possible that you are trying to write files into whatever your current directory is, and that might be a location that you do not have write access to.
We would need to know what your current directory is, and we would need to see more of your code.

请先登录,再进行评论。

回答(1 个)

Yu Jiang
Yu Jiang 2014-8-27
编辑:Yu Jiang 2014-8-27
There should be no spaces in the path or the file name.
  1 个评论
Walter Roberson
Walter Roberson 2018-5-30
This is not really correct. There is no problem in MATLAB in writing files inside directories that happen to have spaces in the name, and no problem writing files that have spaces in the name.
Historically, Simulink was not properly configured in a number of locations and so historically Simulink did have problems with directories or files that had spaces in the name.
But the problem in the original posting had to do with users attempting to write inside the Program Files directory, which Microsoft does not permit users to write into.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by