Error using copyfile, Cannot write to destination

115 views (last 30 days)
Really hoping someone can help. Matlab (version 2021b) seems unable to write to destination folders. When using the
copyfile
command, I get the following error in my command window:
Error using copyfile
Cannot write to destination: C:\Users\...
Use the 'f' option to override.
Where of course the dots (...) represent the actual folder that Matlab is trying to write to. It would be really helpful if someone could help me fix this error. Thanks in advance!

Answers (1)

Bryant Lash
Bryant Lash on 21 Oct 2021
So it's telling you what to do in that function. In stead of using
copyfile(source,dest);
you have to use
copyfile(source,dest,'f');
to force the copy. If that doesn't work, then the issue is that matab doesn't have the right permissions and you'll have to open matlab as admin.
If that still doesn't work, I imagine windows can't copy there either and it's a great lock that windows is placing on that location - there's nothign (reasonable) that can be done about it from matlab.

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!