Unable to copyfile from server (Access is denied)
6 views (last 30 days)
Show older comments
I try to copy file from server but matlab response "Error using copyfile, Access is denied".
I manage to copy out manually from server to local folder but its not happen using Matlab. Can anyone help?
below are my code.
p1 = 'T:\Program\' ;
pdest = 'C:\' ;
filename = 'gitr.zip';
source = fullfile(p1,filename);
destination = fullfile(pdest,filename);
mkdir 'C:\gitr\' ;
% Check if file exist in destination folder,if yes, delete file
if exist(destination) > 0
[status, message, messageid]= rmdir('C:\gitr\','s') ;
delete(destination) ;
fprintf('Unloading TP.........\n');
fprintf('TP unloaded sucessfully\n');
end
fprintf('Loading TP.........\n');
copyfile(source,pdest,'f');
2 Comments
dpb
on 21 Mar 2025
You will need to be able to map the network drive including any necessary credentials to sign in in order to be able to see the network drive...
Walter Roberson
on 21 Mar 2025
I do not understand why you create C:\gitr\ at all, let alone why you conditionally remove it. Your destination file is going to be C:\gitr.zip which does not involve C:\gitr\ at all.
If your logic is to check whether the unzipped version already exists, then if you are just wanting to skip creating the directory and will be copying the file anyhow, then
destdir = 'C:\gitr';
if ~isdir(destdir); mkdir(destdir); end
If your logic is to skip copying the file when the destination directory already exists (under the assumption that existence of the directory implies the zip file has already been unzipped successfully) then the copyfile() should be conditional...
Answers (0)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!