Hi,
I'm using save() to save a workspace variable on a network share. Sometimes, the share is temporarily unavailable. How can I instruct save to give up trying to save the file after a specified timeout?
Thanks!

4 Kommentare

Walter Roberson
Walter Roberson am 3 Feb. 2014
It is best to avoid this situation. Save locally if you can, and then once the data is written, copy it to the network share. This will also be faster.
Matthias
Matthias am 12 Feb. 2014
That's what I'm doing, but even when just copying data, I don't want to wait for the pre-set timeout if the share isn't available. It takes minutes until save() throws an error, although from experience, I know that the share is unavailable unless the save command works ~immediately.
Walter Roberson
Walter Roberson am 12 Feb. 2014
Avoid doing the save() to a share. save() locally. copyfile() afterwards.
Is there a way at the Windows command level to tell if the share is available?
Matthias
Matthias am 10 Mär. 2014
What is the advantage of copyfile() over save() with respect to gracefull handling disk access problems?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Sean de Wolski
Sean de Wolski am 10 Mär. 2014

0 Stimmen

Try to open a file on the drive first, if you can't open it, then the drive is unavailable. Overall, Walter's approach is better and more stable, though and I would recommend following it.
fid = fopen(fullfile(thedrectory,'Arandomfile.txt'),'w');
if fid == -1
error('Couldn''t open')
end

Kategorien

Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 3 Feb. 2014

Beantwortet:

am 10 Mär. 2014

Community Treasure Hunt

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

Start Hunting!

Translated by