Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
show all files from a folder
misiek
3/1/2006 7:43:00 PM
I can not find nothing about files in google,
how to create delete, how to show all files from a folder
if you can redirect me to some web site I'd appreciate
thanks
4 Answers
Jared Richardson
3/1/2006 7:46:00 PM
0
"misiek" <michaelaugustyniak@gazeta.pl> wrote in message
news:du4tf9$8g5$1@inews.gazeta.pl...
>I can not find nothing about files in google,
> how to create delete, how to show all files from a folder
>
> if you can redirect me to some web site I'd appreciate
> thanks
Here's the website I use:
http://www.rubycentra...
Check out Dir and File
Here's some sample code I've been tinkering with that should get you
started.
def findDirs (thisDir)
Dir.entries(thisDir).each { |x|
next if [ "." , ".." ].include? x
thisFile = File.join(thisDir,x)
case File.ftype(thisFile)
when "directory"
puts "Found a directory: "+thisFile
findDirs(thisFile)
when "file"
#puts "Found a file! "+File.join(thisDir, x)
end
}
end
DirHelper.new.findDirs(ARGV[0])
end
Jared
http://JaredRich...
James Gray
3/1/2006 8:06:00 PM
0
On Mar 1, 2006, at 1:43 PM, misiek wrote:
> I can not find nothing about files in google,
> how to create
File.open("my_file.txt", "w") { |f| f.puts "A line in the file." }
> delete
File.unlink "my_file.txt"
> how to show all files from a folder
puts Dir["path/to/dir/*"]
> if you can redirect me to some web site I'd appreciate
Try browsing through the methods of File and Dir in the docs:
http://www.ruby-doc...
Hope that helps.
James Edward Gray II
Tom Wilcoxen
3/1/2006 8:14:00 PM
0
Try Dir and File:
my_dir = Dir["C:/workspaces/Source/**/*.rb"] # collect all the
ruby files recursively
my_dir.each do |filename|
puts filename
File.open(filename, "r") do |f|
puts f
end
end
Here's a good place to start:
http://ruby-doc.org/docs/Progra...
Look for Dir and File.
-Tom
On 3/1/06, misiek <michaelaugustyniak@gazeta.pl> wrote:
> I can not find nothing about files in google,
> how to create delete, how to show all files from a folder
>
> if you can redirect me to some web site I'd appreciate
> thanks
>
>
misiek
3/1/2006 8:50:00 PM
0
thank you all of you for help :)
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
show all files from a folder
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password