Solved

Force file overwrite

Posted on 2007-03-26
7
778 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

713 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