Daniel Berger
3/31/2006 4:02:00 PM
Richard wrote:
> Hi All,
<snip>
> If that's correct, all I have to do is write some loop that naps and
> re-attempts the deletion until successful. Is there better approach,
> or is my analysis wrong in the first place?
>
> ********* Code fragment ****************
> puts "\nDisplaying the content of #{fno}:"
> puts "Opening #{fno}'"
> File.open(fno, "r") do |file| # Open for reading
> while sLine = file.gets
> puts sLine
> end
> end # File will be closed automantically when scope of "do" exited
> puts "#{fno} closed"
>
> puts "\nDeleting #{fno}"
> File.delete(fno)
> *************************************************
It looks like you're passing around a fileno. If that's the case, the
implication is that you've opened the filehandle somewhere else, but
haven't closed it.
Also, you're better off using IO.foreach(file) instead of the File.open
block you've got there.
Regards,
Dan