Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Rename File with FSO
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



Report this thread to moderator Post Follow-up to this message
Old Post
tom
10-29-04 01:55 PM


RE: Rename File with FSO
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 ow
n
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
>
>
>

Report this thread to moderator Post Follow-up to this message
Old Post
StephenMcC
10-29-04 01:55 PM


Re: Rename File with FSO
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...
> 
>
> ...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.
> 
>
> 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:
> 
give 
substituting 
between 2 



Report this thread to moderator Post Follow-up to this message
Old Post
tom
10-29-04 01:55 PM


Re: Rename File with FSO
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" <tgiom@libero.it> wrote in message
news:emAiG2YvEHA.1564@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
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Ray Costanzo [MVP]
10-29-04 08:55 PM


Re: Rename File with FSO
http://www.aspfaq.com/2074
http://www.aspfaq.com/2039#rename

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




"tom" <tgiom@libero.it> wrote in message
news:emAiG2YvEHA.1564@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
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Aaron [SQL Server MVP]
10-29-04 08:55 PM


Re: Rename File with FSO
the original is not there anymore, so dont try and delete it after you have
moved it. its not there.


"StephenMcC" <StephenMcC@discussions.microsoft.com> wrote in message
news:527BD0C5-85F0-420D-8E80-997D63FC7265@microsoft.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...
> 
>
> ...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.
> 
>
> 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:
> 
give 
substituting 
between 2 



Report this thread to moderator Post Follow-up to this message
Old Post
thorpe
10-29-04 08:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

ASP archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:23 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.