Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Weird copyfile rror

Status
Not open for further replies.

thysonj

Programmer
Jul 6, 2001
240
US
Code:
Set cssFile = objFSO.CopyFile(theFile,albumPath)
actually works and copies the file but I get an error...
Code:
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: '[undefined]'
/album/filebuilder.asp, line 42

on the line of the CopyFile. The FileSystemObject works fine everywhere else in the script.
 
Try changing the line to this:

objFSO.CopyFile(theFile,albumPath)

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Actually...i was using strings in the CopyFile call like...
Code:
Set cssFile = objFSO.CopyFile("c:\file.txt","c:\inetpub\")
If i throw the paths into variables like my initial example I get an erro like this
Code:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'objFSO.CopyFile(...)'
/album/filebuilder.asp, line 42
 
TomThumbKP..

That worked!?!

Not quite sure I understand why that doesn't need a set call like when writing a file but whatever.
 
Hello thysonj,

[1] .copyfile does not return an object-type, hence, it will error out using set keyword.

[2] In fact .copyfile does not return anything. It returns empty. This is correct :
[tt]
cssFile = objFSO.CopyFile("c:\file.txt","c:\inetpub\")
or
cssFile = objFSO.CopyFile("c:\file.txt","c:\inetpub\",true)
[/tt]
But cssFile is characterized as:
[tt]
cssFile=empty
vartype(cssFile)=0
[/tt]
[3] But, if you neglect the left-hand-side, then you should not use parenthesis.
[tt]
objFSO.CopyFile "c:\file.txt","c:\inetpub\"
or
objFSO.CopyFile "c:\file.txt","c:\inetpub\", true
[/tt]
regards - tsuji
 
Further notes:

[3a] If you really want parenthesis, use call keyword.
[tt]
call objFSO.CopyFile("c:\file.txt","c:\inetpub\")
or
call objFSO.CopyFile("c:\file.txt","c:\inetpub\", true)
[/tt]
- tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top