Error using rmdir when trying to remove folder

17 次查看(过去 30 天)
Hi
I am trying to remove a folder and all its contents during each run of the for loop. This is the code:
cd 'C:\Temp\A2matlab'
rmdir PsDTestHM1 s
This works well for a few runs and then stops and gives me the following error:
Error using rmdir
C:\Temp\A2matlab\PsDTestHM1\PsDTestHM1.log could not be removed.
C:\Temp\A2matlab\PsDTestHM1 could not be removed.
Error in AbaqusPS (line 1356)
rmdir PsDTestHM1 s
Any suggestions as to what I could be doing wrong?
Thank you.

回答(1 个)

Walter Roberson
Walter Roberson 2017-4-24
The files are probably in use. For example you might need to fclose('all') if you wrote to them from within MATLAB. If the log file is a diary then you need to turn diary off (or change diary destinations.) If some external program is writing to the files, you need to make sure the external program has finished.

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by