469,275 Members | 1,818 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

Rename File with FSO

tom
Hi lads -
got an issue with renaming a file. I'm actually using the FSO method
'MoveFile'.I did try to do my best, but doesn't want to work.
this is the code:

Dim fso
set fso = Server.CreateObject("Scripting.FileSystemObject")
fso.MoveFile Server.MapPath("/document/&session("nome_file")&"), _

Server.MapPath("/document/&session("id_risp")&"_"&session("id_recl")&")
' fso.DeleteFile "session("nome_file")"
set fso = nothing

I tell you I tried to get the valuesof the 3 sessions and all of them give
me back a certain value
which is a good point, so the only thing I should do is just substituting
the first name(which would be
the file am going to upload) to the second one(which is the union between 2
different IDs)
the response I get by processing this page is the classic ' Error 500 '
if u got any clues, please let me know.
thanks in advance
- tommy
Jul 21 '05 #1
6 10725
Hi Tom,

Pretty sure this method should work, used it before myself, what I would
suggest is to do a test harness in VB or .vbs to test the movefile on its own
and then migrate to ASP...
Dim fso
set fso = Server.CreateObject("Scripting.FileSystemObject")
fso.MoveFile Server.MapPath("/document/&session("nome_file")&"), _

Server.MapPath("/document/&session("id_risp")&"_"&session("id_recl")&")
' fso.DeleteFile "session("nome_file")"
set fso = nothing
....After taking a closer look ur code loks a bit odd, shouldn't this be
sumthing like:

Dim fso
set fso = Server.CreateObject("Scripting.FileSystemObject")
fso.MoveFile Server.MapPath("/document/" & session("nome_file")), _
Server.MapPath("/document/" & session("id_risp") & "_" & session("id_recl"))
'I'm guess delete the orginal...
fso.DeleteFile Server.MapPath("/document/" & session("nome_file"))
set fso = nothing

...that is assuming that the Server.MapPath call will provide the full
correct path to the files etc, which I guess it should.
the response I get by processing this page is the classic ' Error 500 '
if u got any clues, please let me know.
Ur browser may be configured not to show server error message,
re-configurable @:
IE6 - Tool -> Options -> Advanced -> Show Friendly HTTP Error Messages
(un-check if checked!)

Hope this helps,

Stephen
..

"tom" wrote:
Hi lads -
got an issue with renaming a file. I'm actually using the FSO method
'MoveFile'.I did try to do my best, but doesn't want to work.
this is the code:

Dim fso
set fso = Server.CreateObject("Scripting.FileSystemObject")
fso.MoveFile Server.MapPath("/document/&session("nome_file")&"), _

Server.MapPath("/document/&session("id_risp")&"_"&session("id_recl")&")
' fso.DeleteFile "session("nome_file")"
set fso = nothing

I tell you I tried to get the valuesof the 3 sessions and all of them give
me back a certain value
which is a good point, so the only thing I should do is just substituting
the first name(which would be
the file am going to upload) to the second one(which is the union between 2
different IDs)
the response I get by processing this page is the classic ' Error 500 '
if u got any clues, please let me know.
thanks in advance
- tommy

Jul 21 '05 #2
tom
Hi Steve -
thank you very much for your advices. it's been really useful.
still don't know the VB even if is really close to vbs.
anyway now seems to run properly even if I got a little prob with the path.
hope will be not too hard to sort out.
cheers
- tom
Hi Tom,

Pretty sure this method should work, used it before myself, what I would
suggest is to do a test harness in VB or .vbs to test the movefile on its own and then migrate to ASP...
Dim fso
set fso = Server.CreateObject("Scripting.FileSystemObject")
fso.MoveFile Server.MapPath("/document/&session("nome_file")&"), _

Server.MapPath("/document/&session("id_risp")&"_"&session("id_recl")&")
' fso.DeleteFile "session("nome_file")"
set fso = nothing
...After taking a closer look ur code loks a bit odd, shouldn't this be
sumthing like:

Dim fso
set fso = Server.CreateObject("Scripting.FileSystemObject")
fso.MoveFile Server.MapPath("/document/" & session("nome_file")), _
Server.MapPath("/document/" & session("id_risp") & "_" &

session("id_recl")) 'I'm guess delete the orginal...
fso.DeleteFile Server.MapPath("/document/" & session("nome_file"))
set fso = nothing

..that is assuming that the Server.MapPath call will provide the full
correct path to the files etc, which I guess it should.
the response I get by processing this page is the classic ' Error 500 '
if u got any clues, please let me know.


Ur browser may be configured not to show server error message,
re-configurable @:
IE6 - Tool -> Options -> Advanced -> Show Friendly HTTP Error Messages
(un-check if checked!)

Hope this helps,

Stephen
.

"tom" wrote:
Hi lads -
got an issue with renaming a file. I'm actually using the FSO method
'MoveFile'.I did try to do my best, but doesn't want to work.
this is the code:

Dim fso
set fso = Server.CreateObject("Scripting.FileSystemObject")
fso.MoveFile Server.MapPath("/document/&session("nome_file")&"), _

Server.MapPath("/document/&session("id_risp")&"_"&session("id_recl")&")
' fso.DeleteFile "session("nome_file")"
set fso = nothing

I tell you I tried to get the valuesof the 3 sessions and all of them give me back a certain value
which is a good point, so the only thing I should do is just substituting the first name(which would be
the file am going to upload) to the second one(which is the union between 2 different IDs)
the response I get by processing this page is the classic ' Error 500 '
if u got any clues, please let me know.
thanks in advance
- tommy

Jul 21 '05 #3
tom
Still got a brand new prob about where saving my file.
by default the file is going to be saves into the 'document' folder declared
in the path.
but it is a physical path and not virtual. -->
C:\..\inetpub\wwwroot\document\ID1_ID2.txt
what I should do is saving the file on the server
so what I did is create a new var with the physical path of the the server
IP and so on.
and what I get is this error:
Server.MapPath() error 'ASP 0172 : 80004005'

Invalid Path

The Path parameter for the MapPath method must be a virtual path. A physical
path was used.

What can I do? cheers
Jul 21 '05 #4
Another option is to just set the .Name property of a file object. That
property is read/write. Example:

Set fso = CreateObjet("Scripting.FileSystemObject")
Set oFile = fso.GetFile(Server.MapPath("/document/" & Session("home_file"))
oFile.Name = "NewFilename.txt"
Set oFile = Nothing
Set fso = Nothing

Ray at work
"tom" <tg***@libero.it> wrote in message
news:em**************@TK2MSFTNGP09.phx.gbl...
Hi lads -
got an issue with renaming a file. I'm actually using the FSO method
'MoveFile'.I did try to do my best, but doesn't want to work.
this is the code:

Dim fso
set fso = Server.CreateObject("Scripting.FileSystemObject")
fso.MoveFile Server.MapPath("/document/&session("nome_file")&"), _

Server.MapPath("/document/&session("id_risp")&"_"&session("id_recl")&")
' fso.DeleteFile "session("nome_file")"
set fso = nothing

I tell you I tried to get the valuesof the 3 sessions and all of them give
me back a certain value
which is a good point, so the only thing I should do is just substituting
the first name(which would be
the file am going to upload) to the second one(which is the union between
2
different IDs)
the response I get by processing this page is the classic ' Error 500 '
if u got any clues, please let me know.
thanks in advance
- tommy

Jul 21 '05 #5
http://www.aspfaq.com/2074
http://www.aspfaq.com/2039#rename

--
http://www.aspfaq.com/
(Reverse address to reply.)


"tom" <tg***@libero.it> wrote in message
news:em**************@TK2MSFTNGP09.phx.gbl...
Hi lads -
got an issue with renaming a file. I'm actually using the FSO method
'MoveFile'.I did try to do my best, but doesn't want to work.
this is the code:

Dim fso
set fso = Server.CreateObject("Scripting.FileSystemObject")
fso.MoveFile Server.MapPath("/document/&session("nome_file")&"), _

Server.MapPath("/document/&session("id_risp")&"_"&session("id_recl")&")
' fso.DeleteFile "session("nome_file")"
set fso = nothing

I tell you I tried to get the valuesof the 3 sessions and all of them give
me back a certain value
which is a good point, so the only thing I should do is just substituting
the first name(which would be
the file am going to upload) to the second one(which is the union between 2 different IDs)
the response I get by processing this page is the classic ' Error 500 '
if u got any clues, please let me know.
thanks in advance
- tommy

Jul 21 '05 #6
the original is not there anymore, so dont try and delete it after you have
moved it. its not there.
"StephenMcC" <St********@discussions.microsoft.com> wrote in message
news:52**********************************@microsof t.com...
Hi Tom,

Pretty sure this method should work, used it before myself, what I would
suggest is to do a test harness in VB or .vbs to test the movefile on its own and then migrate to ASP...
Dim fso
set fso = Server.CreateObject("Scripting.FileSystemObject")
fso.MoveFile Server.MapPath("/document/&session("nome_file")&"), _

Server.MapPath("/document/&session("id_risp")&"_"&session("id_recl")&")
' fso.DeleteFile "session("nome_file")"
set fso = nothing
...After taking a closer look ur code loks a bit odd, shouldn't this be
sumthing like:

Dim fso
set fso = Server.CreateObject("Scripting.FileSystemObject")
fso.MoveFile Server.MapPath("/document/" & session("nome_file")), _
Server.MapPath("/document/" & session("id_risp") & "_" &

session("id_recl")) 'I'm guess delete the orginal...
fso.DeleteFile Server.MapPath("/document/" & session("nome_file"))
set fso = nothing

..that is assuming that the Server.MapPath call will provide the full
correct path to the files etc, which I guess it should.
the response I get by processing this page is the classic ' Error 500 '
if u got any clues, please let me know.


Ur browser may be configured not to show server error message,
re-configurable @:
IE6 - Tool -> Options -> Advanced -> Show Friendly HTTP Error Messages
(un-check if checked!)

Hope this helps,

Stephen
.

"tom" wrote:
Hi lads -
got an issue with renaming a file. I'm actually using the FSO method
'MoveFile'.I did try to do my best, but doesn't want to work.
this is the code:

Dim fso
set fso = Server.CreateObject("Scripting.FileSystemObject")
fso.MoveFile Server.MapPath("/document/&session("nome_file")&"), _

Server.MapPath("/document/&session("id_risp")&"_"&session("id_recl")&")
' fso.DeleteFile "session("nome_file")"
set fso = nothing

I tell you I tried to get the valuesof the 3 sessions and all of them give me back a certain value
which is a good point, so the only thing I should do is just substituting the first name(which would be
the file am going to upload) to the second one(which is the union between 2 different IDs)
the response I get by processing this page is the classic ' Error 500 '
if u got any clues, please let me know.
thanks in advance
- tommy

Jul 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by jez123456 | last post: by
1 post views Thread by Jay at SCA | last post: by
2 posts views Thread by Bruce Russell | last post: by
12 posts views Thread by mantrid | last post: by
1 post views Thread by spacehopper_man | last post: by
2 posts views Thread by =?iso-8859-1?b?cultaQ==?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.