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

2 visualizaciones (últimos 30 días)
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 comentarios
Ade Aulya
Ade Aulya el 30 de Mayo de 2018
Editada: Walter Roberson el 30 de Mayo de 2018
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 el 30 de Mayo de 2018
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.

Iniciar sesión para comentar.

Respuestas (1)

Yu Jiang
Yu Jiang el 27 de Ag. de 2014
Editada: Yu Jiang el 27 de Ag. de 2014
There should be no spaces in the path or the file name.
  1 comentario
Walter Roberson
Walter Roberson el 30 de Mayo de 2018
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by