File copy

Hi

I am having a weird problem. I have the following code.

require “fileutils”

FileUtils.cp ‘/path/to/file.txt’, ‘/path/to/archive/file-date.txt’

File.open(’/path/to/file.txt’, ‘w’)

What I want to do is copy file.txt content to file-date.txt in a sub
directory, then reset file.txt to empty.

But after I run the code above, both file.txt and file-date.txt are
reset to empty file. What am I missing here?

Thanks a lot!

2010/5/27 John Wu [email protected]:

I am having a weird problem. I have the following code.

require “fileutils”

FileUtils.cp ‘/path/to/file.txt’, ‘/path/to/archive/file-date.txt’

File.open(‘/path/to/file.txt’, ‘w’)

You also need to close the file.

What I want to do is copy file.txt content to file-date.txt in a sub
directory, then reset file.txt to empty.

But after I run the code above, both file.txt and file-date.txt are
reset to empty file. What am I missing here?

Maybe /path/to/file.txt is a symlink or /path/to is liked to
/path/to/archive or /path/to/file.txt is really the same as
/path/to/archive/file-date.txt. Somehow I have the feeling you don’t
show the real code.

Kind regards

robert

John Wu wrote:

FileUtils.cp ‘/path/to/file.txt’, ‘/path/to/archive/file-date.txt’

File.open(’/path/to/file.txt’, ‘w’)

What I want to do is copy file.txt content to file-date.txt in a sub
directory, then reset file.txt to empty.

But after I run the code above, both file.txt and file-date.txt are
reset to empty file. What am I missing here?

It seems everything is ok in my computer!