I can't delete the file obtained with matlab
19 ビュー (過去 30 日間)
古いコメントを表示
.....
writecell(bu,hhh,'Delimiter',' ');
when I kill writecell process (using ctrl+c) in matlab i receive this error and if i try to delete file
i receive this error:
The operation could not be completed because the file is open in matlab R2024a
0 件のコメント
採用された回答
dpb
2024 年 7 月 21 日
移動済み: dpb
2024 年 7 月 21 日
You'll have to exit and restart MATLAB, then...
I've never had MATLAB keep the file handle open; Excel if using ActiveX and crash, yes, but not MATLAB.
Somehow the error handler/cleanup function isn't managing to close the open file and let the OS know. That is worthy of a bug report, but it is probably not reliably reproducible.
But, Ctrl-C while writing a file is risky behavior although ideally it should be able to be handled...
3 件のコメント
dpb
2024 年 7 月 21 日
There is no provided facility for that; you would have to stuff the Ctrl-C into the keyboard buffer and drawnow to update callbacks (and not sure that would work). Such things should be avoided.
The only clean way to do something of that sort would be to not dispatch the writecell call with the entire file but in a loop and check for user cancellation at the end of each pass through the loop. This would obviously add even more overhead and have a latency period (MsgBox("Please Standby")) until the current call completes and can check the flag to terminate.
What and how large a file are you writing such that it is wanted to cancel the operation? If the user asked to write the file, it would seem a fairly rare event to then subsequently want to cancel?
I think it may be worth a support request to Mathworks about the open file handle from the command line to see if they think that is expected behavior or not despite the poor practice from user. I would think the registered cleanup functions should be able to deal with it cleanly, but it's worth asking about. As said, I've not seen the symptom, but I've not done the exercise that often and don't have that release of MATLAB installed.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Introduction to Installation and Licensing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!