473,399 Members | 2,774 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,399 software developers and data experts.

Rename a file which held in server using asp

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.MapPa th("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.
Mar 4 '08 #1
7 3195
<ja*******@gmail.comwrote in message
news:bc**********************************@d4g2000p rg.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.MapPa th("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.
Mar 4 '08 #2
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.
Mar 5 '08 #3
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
Mar 5 '08 #4
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"));

Mar 5 '08 #5
wrote on 05 mrt 2008 in microsoft.public.inetserver.asp.general:
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").
This escaping the \ depends on your using ASP-JS or ASP-VBS.
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.
This is as it should be. The ASP user should not have permission to access
the whole of the c: hd. In an of-web environment you could change te
permission, but that is outside the ASP Topic.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 5 '08 #6
Evertjan.
That is correct. Thanks. I change the permission of the
folder and allow modify permission to internet guest account in my
local system and it works properly. Then allow the same to the folder
in website and it also works properly.

jain
Mar 6 '08 #7
wrote on 06 mrt 2008 in microsoft.public.inetserver.asp.general:
Evertjan.
That is correct.
??

[please always quote on usenet]
Thanks. I change the permission of the
folder and allow modify permission to internet guest account in my
local system and it works properly. Then allow the same to the folder
in website and it also works properly.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 6 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Abhishek | last post by:
I have a problem transfering files using sockets from pocket pc(.net compact c#) to desktop(not using .net just mfc and sockets 2 API). The socket communication is not a issue and I am able to...
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: 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...
10
by: Don Curtis | last post by:
I have a C# client app that sometimes needs to do thousands of specialized file renames of files on a file server in the same domain. If the files reside locally on the client machine, the renames...
3
by: OdAwG | last post by:
Hello All, I would i check to see if a file exist and if it does exist, then rename the file with the date and time attached to the name: Example: If...
1
by: cheesey_toastie | last post by:
I have a long query which I have set off and would like to stop, and rename one of the tables used. My query is due to my lack of understanding of the underlying structure of MSSQL-Server... ...
92
by: ureuffyrtu955 | last post by:
Python is a good programming language, but "Python" is not a good name. First, python also means snake, Monty Python. If we search "python" in google, emule, many results are not programming...
1
by: ogo796 | last post by:
hi everyone i upload files everyday to the server using a php coded program , it works from other computers but not on the others. Could this be a problem with http headers of specific computers...
1
by: achotto | last post by:
hi, i try to upload a multiple image files. after that i will rename the files name. the problem is when i upload a 2 or more same files name exp-goal.jpg, it will return "files already exist". ok...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...

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.