473,243 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,243 software developers and data experts.

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 11192
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Tom | last post by:
I'm having a problem using a path with spaces as a parameter to os.rename() in a program on WinXP. This works fine at the command line (where the folder "c:\aa bb" exists) > os.rename( "c\aa...
5
by: jez123456 | last post by:
Hi, I’ve written a c# program to compact certain msaccess databases. The way this works is to compact say C:\test1.mdb to C:\temp.mdb, then delete C:\test1.mdb and rename C:\temp.mdb as...
1
by: Jay at SCA | last post by:
I've been having the following issue with a windows service I've created in vb.net (.net fw 1.1): Basically, my service monitors a folder for the creation of any new files of a particular type...
2
by: Bruce Russell | last post by:
This may sound stupid but I can't rename the WebForm1.aspx in the solution explorer. The file is located in my local web server at C:\Inetpub\wwwroot\Lab3-VB-Starter\WebForm1.aspx Is there...
5
by: Rothariger | last post by:
Hello.... i want to know if its posible to rename multiple files like windows does.. example: file zzzzzzz.doc file asdasd.doc file esfsefse.doc
5
by: Tony Meyer | last post by:
On Windows, if I do os.rename(old, new) where old is a file that is in-use (e.g. python itself, or a dll that is loaded), I would expect that an error would be raised (e.g. as when os.remove is...
5
by: VB Programmer | last post by:
My web hoster says that I have to rename my ASPNETDB.MDF SqlExpress db for my 2.0 site to work. Is this accurate? If so, how can I rename it without breaking anything on my site? FYI: This is...
12
by: mantrid | last post by:
Im trying to move a file but am having luck my code is below. The temp and target paths are valid as they echo correctly. but I cant get the copy() function to work, or the rename() function ...
1
by: spacehopper_man | last post by:
no "rename" operation in C# !!! - this has been covered in this group before, but I can't find any good answers. what I am trying to do is refresh the content in a file with minimum...
2
by: =?iso-8859-1?b?cultaQ==?= | last post by:
Hi, I would like to rename files (jpg's ones) using a text file containing the new names... Below is the code that doesn't work : ***** #!/usr/bin/python #-*- coding: utf-8 -*- from os...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.