Force timeout for save()?
显示 更早的评论
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 个评论
Walter Roberson
2014-2-3
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
2014-2-12
Walter Roberson
2014-2-12
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
2014-3-10
回答(1 个)
Sean de Wolski
2014-3-10
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
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!