Using movefile with FSO

Results 1 to 2 of 2

Thread: Using movefile with FSO

  1. #1
    Join Date
    Dec 1969

    Default Using movefile with FSO

    Does anybody have problems using the movefile command with the filesystemobject command. I can&#039;t get it work properly. It keeps giving me an error trying to use it. Here&#039;s the following code.<BR><BR>if request.form("submit") = "Move File" then<BR><BR>set fsostream = server.createobject("scripting.filesystemobject")< BR><BR>for each k in request.form("move")<BR>if fsostream.fileexists(session("cdir") & k) = false then<BR>else<BR>fsostream.movefile(session("cdir") & k,fol & mname & "\" & myday1 & "\")<BR><BR>end if<BR><BR>next<BR><BR>end if<BR><BR><BR><BR>here is the error that follows the code<BR><BR><BR>Cannot use parentheses when calling a Sub <BR><BR>/user scripts/default.asp, line 37 <BR><BR>fsostream.movefile(session("cdir") & k,fol & mname & "\" & myday1 & "\")<BR>------------------------------------------------------------------------^<BR><BR><BR><BR>What I don&#039;t understand is why it thinks this is a sub?<BR>

  2. #2
    Join Date
    Dec 1969

    Default Because it *IS* a Sub!

    You aren&#039;t getting any return value are you???<BR><BR>That is, you aren&#039;t doing<BR>&#060;%<BR>someVar = FSO.MoveFile...<BR>%&#062;<BR>are you?<BR><BR>You are, indeed, using MoveFile as a SUB. And so you must follow VBS&#039;s rules about calling subs.<BR><BR>Either don&#039;t put in the parens or use the CALL keyword.<BR><BR>Period.<BR><BR>Nothing whatsoever to do with FSO.<BR><BR>Incidentally, did you know that Response.Write is a SUB? So how come people use<BR>&nbsp; &nbsp; Response.Write ( ... )<BR>And how come they get away with it?<BR><BR>Hmmm??? There are articles on 4Guys with the answer, from yours truly. But see if you can figure it out first.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts