Solved

Force file overwrite

Posted on 2007-03-26
7
775 Views
Last Modified: 2008-01-09
I'm using this to write images to the server

 Request.Files[IntLoop].SaveAs(Server.MapPath(".\\hotels\\hotel_images\\" + hotelid + "_"+ (IntLoop + 1) + "." + exts));

How can I force it to overwrite the image if exists, I keep getting
The process cannot access the file ....
0
Comment
Question by:Gary
7 Comments
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 18796472
Does IUSR_machinename have write access to the folder?
0
 
LVL 25

Expert Comment

by:kevp75
ID: 18796683
you also made need to see if the file is read-only...

I wonder if there is a flag to do the overwrite....
0
 
LVL 58

Author Comment

by:Gary
ID: 18801088
There is full access to the folder, when the image doesnt exist in the first place its fine, messing around I did a delete first if the image existed followed by a sleep before writing the new image - but this is impractical
As Kev said there must be some flag, in vb you add True to the end of the argument, but this doesnt work in c#
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 58

Author Comment

by:Gary
ID: 18801355
After some testing the problem seems to lie in the getimage.aspx, when I remove the call to this page the uploading works fine, but I can't see what the problem is with this file, everything is disposed etc

You can get the full script at
http://eyeonireland.com/upload.aspx.txt
http://eyeonireland.com/getimage.aspx.txt

...if you want to try testing locally.
0
 
LVL 58

Author Comment

by:Gary
ID: 18801403
Ahh solved it, wasnt disposing of
i = System.Drawing.Image.FromFile(strFilename)

:)
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 19279638
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now