confirm valid file identifier before flcose?
古いコメントを表示
I am using GUI callbacks to close a file. Sometimes the file is aready closed, and I get an invalid file identifier error. Is there a robust way to check if the file is still open before calling fclose? I have tried using fopen('all') but that does not always catch it.
採用された回答
その他の回答 (2 件)
Voss
2024 年 2 月 1 日
try
fclose(fid);
catch
% file already closed, do nothing
end
カテゴリ
ヘルプ センター および File Exchange で Entering Commands についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!