フィルターのクリア

Error using writecell() : Permission denied

5 ビュー (過去 30 日間)
Nicholas Brophy
Nicholas Brophy 2020 年 11 月 30 日
回答済み: Nicholas Brophy 2020 年 12 月 1 日
I currently have code in FolderA which runs a function that needs to access csv files in FolderB, but I am being denied permission to edit/enter the folder and its contents, though I (should) have full admin privilages on my computer.
folder = 'C:\Users\...\FolderA\...\FolderB' % folder I want to access containing several csv files
if ~exist(folder, 'dir')
mkdir(folder);
end
fullFileName = fullfile(folder, 'SRM_design.csv');
titles={'A', 'B', 'C', 'D','E','F','G','H','I','J'};
M={300,1,0.05,625,14.7,12.4,0,1,15,0.97};
M=[titles;M];
fname='fullFileName';
writecell(M,fullFileName);
When I run the above within my function, I get this error:
Error using writecell (line 149)
Unable to open file 'C:\Users\...\FolderA\...\FolderB\filename.csv' for writing:
Permission denied
When I run the same function within FolderB it works fine.
I will need to access this folder several times within the code and will need access to the files edited within FolderB.

採用された回答

Nicholas Brophy
Nicholas Brophy 2020 年 12 月 1 日
Checked to reconfirm function runs properly within Folder B. When it didn't work I realized that the document was open in excel and therefore locked for editing. After closing the document it worked just fine again within both folders.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by