Robert Klemme wrote:
> On Thu, Oct 7, 2010 at 8:59 AM, Amit Tomar <amittomer25 / yahoo.com> 
> wrote:
>> Hi all,
>> ? ? ? ? i would like to close a file that is open in particular
>> directory .this is my code
>>
>> require 'fileutils'
>>
>> ? ?dir ="C:/Documents and Settings/x0138466/Local Settings/Temp"
>> ? ?Dir.chdir(dir)
>> ? ?Dir["*"].each do |f|
>> ? ?f.close
> 
> f is a String!  You cannot close a String.
> 
>> ? ? ? ?# ?File.close
>>
>> ? ? ?FileUtils.rm_rf(f)
>> ? ? #FileUtils.rm(f)
>>
>> ?end
>> ? ?Some of the file in TEMP folder is open or you can say used by some
>> process but i want to close but with above code am not ablr to do
>> that??is it possible to achive from above code??
> 
> From your recent postings I conclude that you mean "opened by another
> process".  No, you cannot close a file from another process without
> going through major operating system specific tricks (on Windows there
> is ProcessExplorer of former Sysinternals for example).  You also
> usually need specific privileges, i.e. have root rights on a *nix
> system and have administrative permissions on a Windows box.
> 
> Kind regards
> 
> robert

Thanks for your response robert
i downloaded  a tool handle using which i am able to close the file that 
is in use but i don't know how do i acheve this form ruby code am 
running this command from command prompt to close the file

handle -p 556 -c 750

ruby.exe pid: 556 TIGOC\x0138466
  748: File  (RW-)   C:\Documents and Settings\x0138466\Local 
Settings\Temp
  760: File  (RW-) 
C:\InstantRails-2.0-\rails_apps\upload\log\development.log
  784: File  (RW-) 
C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-00.2982_x-ww_ac3f9c03
  7B0: File  (RW-) 
C:\InstantRails-2.0-\rails_apps\upload\log\development.log
 750: File  (RW-)   C:\DOCUME~1\x0138466\LOCALS~1\Temp\mongrel.556.1
where 750 is the handle i closed
-- 
Posted via http://www.ruby-forum.com/.