From: jain2005k on
How can I rename a .jpg file in server using asp( not asp.net) code

I use the FileSystemObject to do that like
Fso = Server.CreateObject("Scripting.FileSystemObject");
Fso.MoveFile(Server.MapPath("1.jpg"),(Server.MapPath("2.jpg"));
but it does not work properly
when I use the the code in my local system it also not worked.

But when I put full filepathpath instead of mapPath in my local
system. Like
Fso.MoveFile("c:\\inetpub\\1.jpg", "c:\\inetpub\\2.jpg")
It worked properly.

May anyone help me to do this with Server.MapPath() method.
From: McKirahan on
<jain2005k(a)gmail.com> wrote in message
news:bcd9f3cd-a11c-44f1-a0b8-d47fd1371f64(a)d4g2000prg.googlegroups.com...
> How can I rename a .jpg file in server using asp( not asp.net) code
>
> I use the FileSystemObject to do that like
> Fso = Server.CreateObject("Scripting.FileSystemObject");
> Fso.MoveFile(Server.MapPath("1.jpg"),(Server.MapPath("2.jpg"));
> but it does not work properly
> when I use the the code in my local system it also not worked.
>
> But when I put full filepathpath instead of mapPath in my local
> system. Like
> Fso.MoveFile("c:\\inetpub\\1.jpg", "c:\\inetpub\\2.jpg")
> It worked properly.
>
> May anyone help me to do this with Server.MapPath() method.

Sometimes MoveFile hasn't worked for me so I used CopyFile and
DeleteFile. You may want to test for FileExists between the two.


From: Brynn on
Just for testing sake ... try your Server.MapPath("/1.jpg") ... and
same with your 2.jpg

Whenever I use virtual paths, I like to start them from the root
directory. If nothing else, it will be a good way to test your code.
Being that I don't know where the file is that is running your asp.
You have to remember that the virtual path is going to start from the
calling asp file. So if your setup is like this ...
/1.jpg
/2.jpg
/folder/my.asp

Then that is why it isn't working ... because Server.MapPath ... or
anything using a virtual path is using it starting from the calling
asp page ... and just putting 1.jpg would make it think /folder/
1.jpg. To stop that ... always start your virtual paths from the root
directory ... that is all your paths from / being the root of your
website /1.jpg

Without knowing where your asp page this is just added info.
Another example ...

/images/1.jpg
/mycode/myfile.asp

would be Server.MapPath("/images/1.jpg"), Server.MapPath("/images/
2.jpg")

Even though in the code is in a different directory, you got to your
image paths by starting at the root and going forward.

Take care.
From: jain2005k on
Brynn, thanks for your replay.
I change the code as per your suggestion. But it does not work.
I mention the full path
Fso.MoveFile("c:\\inetpub\\1.jpg", "c:\\inetpub\\2.jpg") is just for
example.
It is correctly Fso.MoveFile("c:\\inetpub\\wwwroot\\support\\1.jpg", "
c:\\inetpub\\wwwroot\\support\\2.jpg");.
And the asp file is also in the same folder.( "c:\\inetpub\\wwwroot\
\support\\")
When I use the code as
Fso.MoveFile("c:\\inetpub\\wwwroot\\support\\1.jpg", " c:\\inetpub\
\wwwroot\\support\\2.jpg").
In my local machine it works properly.
But when I use the same code as
Fso.moveFile(Server.MapPath("/support/2.jpg"), Server.MapPath("/
LiveSupport/3.jpg"));
It does not works and print an error

Error Type:
Microsoft JScript runtime (0x800A0046)
Permission denied
/support/Changename.asp.
Is it the problem of permission?. If yes , what can I do for allow
the permission.

Thanks jain
From: jain2005k on
Brynn, there is a small mistake in my previous message
>But when I use the same code as
>Fso.moveFile(Server.MapPath("/support/2.jpg"), Server.MapPath("/
>LiveSupport/3.jpg"));
both folder are same
it is currectly
Fso.moveFile(Server.MapPath("/support/2.jpg"), Server.MapPath("/
support/3.jpg"));