Unable to copyfile from server (Access is denied)
Ältere Kommentare anzeigen
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 Kommentare
dpb
am 21 Mär. 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
am 21 Mär. 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...
Antworten (0)
Kategorien
Mehr zu Package MATLAB Functions finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!