From: Szymon Drejewicz Date: 2009-08-28T05:42:27+09:00 Subject: Re: How to delete a file in Win XP Mateusz Winiarski wrote: > deleting in windows explorer works fine in the same account Yes, it is true. However, if you run your script and forget to close the file, the unlink/delete/rm fails! In Windows Explorer deleting always succeeds because your script is -- probably -- not active. (So, all of your files are closed by Ruby engine, even if you doesn't closed them explicite.) You cannot delete a file that is already open. You have to close it before deletion. WRONG: f = File.open('jadzia','w+') File.unlink('jadzia') =====> ERROR RIGHT: f = File.open('jadzia','w+') f.close File.unlink('jadzia') =====> OK! -- Posted via http://www.ruby-forum.com/.