FileUtils in widows

Discussion in 'Ruby' started by Jonathan Dale, Jul 28, 2007.

  1. I am fairly new to ruby and am working with windows xp. I'm trying to
    copy files from one directory to another using the FileUtils module.
    When I run the program, I get a Permission Denied error (EACCES). Any
    thoughts on how to get this to work?

    files.each do |f|
    next if f == "." or f == ".."
    FileUtils.copy(dir,newdir)
    end

    Thanks in advance for any help.

    jjd
    --
    Posted via http://www.ruby-forum.com/.
     
    Jonathan Dale, Jul 28, 2007
    #1
    1. Advertising

  2. On Jul 28, 5:03 pm, Jonathan Dale <> wrote:
    > I am fairly new to ruby and am working with windows xp. I'm trying to
    > copy files from one directory to another using the FileUtils module.
    > When I run the program, I get a Permission Denied error (EACCES). Any
    > thoughts on how to get this to work?
    >
    > files.each do |f|
    > next if f == "." or f == ".."
    > FileUtils.copy(dir,newdir)


    You forgot to use f in this line.

    > end
     
    William James, Jul 28, 2007
    #2
    1. Advertising

  3. Jonathan Dale

    Jon Dale Guest

    >> files.each do |f|
    >> next if f == "." or f == ".."
    >> FileUtils.copy(dir,newdir)

    >
    > You forgot to use f in this line.


    Isn't the f covered in the do statement? I'm not sure how else f would
    be implemented.
    --
    Posted via http://www.ruby-forum.com/.
     
    Jon Dale, Jul 28, 2007
    #3
  4. On Jul 29, 8:24 am, Jon Dale <> wrote:
    > >> files.each do |f|
    > >> next if f == "." or f == ".."
    > >> FileUtils.copy(dir,newdir)

    >
    > > You forgot to use f in this line.

    >
    > Isn't the f covered in the do statement? I'm not sure how else f would
    > be implemented.


    FileUtils.copy(f, newdir)
     
    Gavin Sinclair, Jul 29, 2007
    #4
  5. Jonathan Dale

    Jon Dale Guest

    Gavin Sinclair wrote:
    > On Jul 29, 8:24 am, Jon Dale <> wrote:
    >> >> files.each do |f|
    >> >> next if f == "." or f == ".."
    >> >> FileUtils.copy(dir,newdir)

    >>
    >> > You forgot to use f in this line.

    >>


    >
    > FileUtils.copy(f, newdir)


    Thanks, works now. I stared at it so long I couldn't see the obvious!
    --
    Posted via http://www.ruby-forum.com/.
     
    Jon Dale, Jul 29, 2007
    #5
  6. On Jul 28, 6:58 pm, Gavin Sinclair <> wrote:
    > On Jul 29, 8:24 am, Jon Dale <> wrote:
    >
    > > >> files.each do |f|
    > > >> next if f == "." or f == ".."
    > > >> FileUtils.copy(dir,newdir)

    >
    > > > You forgot to use f in this line.

    >
    > > Isn't the f covered in the do statement? I'm not sure how else f would
    > > be implemented.

    >
    > FileUtils.copy(f, newdir)


    Or
    FileUtils.copy( "#{dir}/#{f}", newdir)

    FileUtils.copy isn't a mind-reader.
    It doesn't know (or assume) that you have put
    the name of the file in variable named f.
    It doesn't know that it is being invoked
    inside of a loop.
     
    William James, Jul 29, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tariq_swl

    Widows Service Event for LogOff

    tariq_swl, Oct 1, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    521
    tariq_swl
    Oct 1, 2005
  2. Peter

    Parent widows refresh

    Peter, Jul 25, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    12,097
    Peter
    Jul 26, 2005
  3. mahesh
    Replies:
    1
    Views:
    630
    Andrew Thompson
    Dec 7, 2006
  4. David4021

    asp.net 3.5 and ajax on widows 2003

    David4021, Jan 20, 2008, in forum: ASP .Net
    Replies:
    8
    Views:
    2,495
    David4021
    Jan 21, 2008
  5. fatma
    Replies:
    0
    Views:
    106
    fatma
    May 27, 2005
Loading...

Share This Page