Robert Klemme
1/27/2009 6:50:00 AM
On 27.01.2009 07:32, Newb Newb wrote:
> Hi People i have never done file or Directory manipulations before.
> now in my form i have given date field and search button.
> if the user enters date and clicks the search button,accoding to the
> date entered it has to search for the folder in the ChatHistory folder
> for example user enters date like 2009-01-23 means it has to search for
> the folder which named 2009-01-23.
> if the foder exists again it has to be iterated when i do this i get
> error.
> folder structure would be ChatHistory has one folder like 2009-01-23
> has two folder namely test and user these two folders contain 2 files
> each.
> My code starts here
> if params[:first_name].blank? and params[:second_name].blank? and
> !params[:e_date][0].blank? and params[:e_date][1].blank?
> puts "frtst date is not blank others are blank"
> Dir.foreach("ChatHistory") do |f|
> if f == params[:e_date][0]
> puts "there:"
> Dir.foreach(f) do |p|
f does not contain the full path here so you need something like:
Dir.foreach(File.join("ChatHistory",f)) do |p|
Btw, it's often helpful to put a few printing statements here and there
during debugging. :-)
> puts p
> end
> end
> end
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end