473,789 Members | 3,087 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.CreateOb ject("Scripting .FileSystemObje ct")
fso.MoveFile Server.MapPath( "/document/&session("nome_ file")&"), _

Server.MapPath( "/document/&session("id_ri sp")&"_"&sessio n("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 11259
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.CreateOb ject("Scripting .FileSystemObje ct")
fso.MoveFile Server.MapPath( "/document/&session("nome_ file")&"), _

Server.MapPath( "/document/&session("id_ri sp")&"_"&sessio n("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.CreateOb ject("Scripting .FileSystemObje ct")
fso.MoveFile Server.MapPath( "/document/" & session("nome_f ile")), _
Server.MapPath( "/document/" & session("id_ris p") & "_" & session("id_rec l"))
'I'm guess delete the orginal...
fso.DeleteFile Server.MapPath( "/document/" & session("nome_f ile"))
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.CreateOb ject("Scripting .FileSystemObje ct")
fso.MoveFile Server.MapPath( "/document/&session("nome_ file")&"), _

Server.MapPath( "/document/&session("id_ri sp")&"_"&sessio n("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.CreateOb ject("Scripting .FileSystemObje ct")
fso.MoveFile Server.MapPath( "/document/&session("nome_ file")&"), _

Server.MapPath( "/document/&session("id_ri sp")&"_"&sessio n("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.CreateOb ject("Scripting .FileSystemObje ct")
fso.MoveFile Server.MapPath( "/document/" & session("nome_f ile")), _
Server.MapPath( "/document/" & session("id_ris p") & "_" &

session("id_rec l")) 'I'm guess delete the orginal...
fso.DeleteFile Server.MapPath( "/document/" & session("nome_f ile"))
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.CreateOb ject("Scripting .FileSystemObje ct")
fso.MoveFile Server.MapPath( "/document/&session("nome_ file")&"), _

Server.MapPath( "/document/&session("id_ri sp")&"_"&sessio n("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\w wwroot\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("Sc ripting.FileSys temObject")
Set oFile = fso.GetFile(Ser ver.MapPath("/document/" & Session("home_f ile"))
oFile.Name = "NewFilename.tx t"
Set oFile = Nothing
Set fso = Nothing

Ray at work
"tom" <tg***@libero.i t> wrote in message
news:em******** ******@TK2MSFTN GP09.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.CreateOb ject("Scripting .FileSystemObje ct")
fso.MoveFile Server.MapPath( "/document/&session("nome_ file")&"), _

Server.MapPath( "/document/&session("id_ri sp")&"_"&sessio n("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.i t> wrote in message
news:em******** ******@TK2MSFTN GP09.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.CreateOb ject("Scripting .FileSystemObje ct")
fso.MoveFile Server.MapPath( "/document/&session("nome_ file")&"), _

Server.MapPath( "/document/&session("id_ri sp")&"_"&sessio n("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********@dis cussions.micros oft.com> wrote in message
news:52******** *************** ***********@mic rosoft.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.CreateOb ject("Scripting .FileSystemObje ct")
fso.MoveFile Server.MapPath( "/document/&session("nome_ file")&"), _

Server.MapPath( "/document/&session("id_ri sp")&"_"&sessio n("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.CreateOb ject("Scripting .FileSystemObje ct")
fso.MoveFile Server.MapPath( "/document/" & session("nome_f ile")), _
Server.MapPath( "/document/" & session("id_ris p") & "_" &

session("id_rec l")) 'I'm guess delete the orginal...
fso.DeleteFile Server.MapPath( "/document/" & session("nome_f ile"))
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.CreateOb ject("Scripting .FileSystemObje ct")
fso.MoveFile Server.MapPath( "/document/&session("nome_ file")&"), _

Server.MapPath( "/document/&session("id_ri sp")&"_"&sessio n("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
9514
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 bb", "c:\cc dd" ); > But, I can't get it to work in my program, eg.
5
2757
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 C:\test1.mdb. My problem occurs if there is already a C:\temp.mdb file. I don’t want to just delete this, as it could have been created separately by a user. In my code, I set a constant as follows: private const string tempMdb = @"C:\temp.mdb";
1
2006
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 and renames them using the "Rename(oldfilename,newfilename)" function. Unfortunately, this function only seems to work if and only if it is preceeded by a 'msgbox("<some text>")'. ie. If I have the following the service sees the file
2
2963
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 some configuration problem in my IIS setup? Thanks,
5
4465
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
2735
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 called with an in-use file). However, what happens is that a copy of the file is made, and the old file still exists. For example: C:\>c:\python24\python.exe Python 2.4.2 (#67, Sep 28 2005, 12:41:11) on win32
5
3060
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 the error I'm getting after I publish my site to their servers... An attempt to attach an auto-named database for file c:\hosting\myhost\member\myaccount\customerdomains\mysite\App_Data\ASPNETDB.MDF failed. A database with the same name exists,...
12
2907
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 $target_path = $targetdir . basename($uploadedfile); $temp_path = $tempdir. basename($uploadedfile); echo "Target - ".$target_path." Temp - ".$temp_path."<br>";
1
4525
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 performance impact on any read operations to that file - a common task right.... in the unix world the way to do this is to create a temporary file with
2
3637
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 import listdir, getcwd, rename import re
0
9665
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10199
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6768
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3697
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.