473,583 Members | 3,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.drawing. image

Hi,

I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile) that I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documen ts and
Settings\29\Mij n documenten\SubF olderFolder\Img Name.jpg"), I keep getting a
'FileNotFoundEx ception'. That doesn't happen when I get the SourceFile from
"C:\Folder\imgN ame".

What can I do about this ?

Actually I found a workaround, but this gives me an error as well....

I can save the PostedFile like this
PostedFile.Save As(imgPath + "DummyName" );

After which I can do these steps without any problem

System.Drawing. Image srcImage =
System.Drawing. Image.FromFile( imgPath + DummyName);

Graphics graphicOrig = Graphics.FromIm age(srcImage);
graphicOrig.Com positingQuality = CompositingQual ity.HighQuality ;
graphicOrig.Smo othingMode = SmoothingMode.A ntiAlias;
graphicOrig.Int erpolationMode =
InterpolationMo de.HighQualityB icubic;

Rectangle rectOrig = new Rectangle();
graphicOrig.Dra wImage(srcImage , rectOrig);
srcImage.Save(N ewFileName, ImageFormat.Jpe g);

srcImage.Dispos e();

The final srcImage is perfect, and everything I need but when I want to do
this
File.Delete(img Path + dummyName);

I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyN ame' because it is being
used by another process."

Does anyone know what I can do about these issues?

Jan 23 '06 #1
5 2313
Try also

graphicOrig.Dis pose();

--Daniel
http://staff.newtelligence.com/danielf/


-----Original Message-----
From: benoit [mailto:be****@d iscussions.micr osoft.com]
Posted At: Monday, January 23, 2006 12:21 PM
Posted To: microsoft.publi c.dotnet.framew ork.aspnet
Conversation: System.drawing. image
Subject: System.drawing. image

Hi,

I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile)
that I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documen ts and
Settings\29\Mij n documenten\SubF olderFolder\Img Name.jpg"), I keep
getting a
'FileNotFoundEx ception'. That doesn't happen when I get the SourceFile
from
"C:\Folder\imgN ame".

What can I do about this ?

Actually I found a workaround, but this gives me an error as well....

I can save the PostedFile like this
PostedFile.Save As(imgPath + "DummyName" );

After which I can do these steps without any problem

System.Drawing. Image srcImage =
System.Drawing. Image.FromFile( imgPath + DummyName);

Graphics graphicOrig = Graphics.FromIm age(srcImage);
graphicOrig.Com positingQuality =
CompositingQual ity.HighQuality ;
graphicOrig.Smo othingMode = SmoothingMode.A ntiAlias;
graphicOrig.Int erpolationMode =
InterpolationMo de.HighQualityB icubic;

Rectangle rectOrig = new Rectangle();
graphicOrig.Dra wImage(srcImage , rectOrig);
srcImage.Save(N ewFileName, ImageFormat.Jpe g);

srcImage.Dispos e();

The final srcImage is perfect, and everything I need but when I want to
do
this
File.Delete(img Path + dummyName);

I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyN ame' because it is
being
used by another process."

Does anyone know what I can do about these issues?

Jan 23 '06 #2
Try getting the actual path of your posted file from System.IO.Path
namespace. You can use it like this:

string FileName =
System.IO.Path. GetFileName(fil eUpload.PostedF ile.FileName); // fileUpload is
the id of fileupload html control

Zeeshan
http://zishu.blogspot.com
"benoit" <be****@discuss ions.microsoft. com> wrote in message
news:D1******** *************** ***********@mic rosoft.com...
Hi,

I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile) that
I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documen ts and
Settings\29\Mij n documenten\SubF olderFolder\Img Name.jpg"), I keep getting
a
'FileNotFoundEx ception'. That doesn't happen when I get the SourceFile
from
"C:\Folder\imgN ame".

What can I do about this ?

Actually I found a workaround, but this gives me an error as well....

I can save the PostedFile like this
PostedFile.Save As(imgPath + "DummyName" );

After which I can do these steps without any problem

System.Drawing. Image srcImage =
System.Drawing. Image.FromFile( imgPath + DummyName);

Graphics graphicOrig = Graphics.FromIm age(srcImage);
graphicOrig.Com positingQuality =
CompositingQual ity.HighQuality ;
graphicOrig.Smo othingMode = SmoothingMode.A ntiAlias;
graphicOrig.Int erpolationMode =
InterpolationMo de.HighQualityB icubic;

Rectangle rectOrig = new Rectangle();
graphicOrig.Dra wImage(srcImage , rectOrig);
srcImage.Save(N ewFileName, ImageFormat.Jpe g);

srcImage.Dispos e();

The final srcImage is perfect, and everything I need but when I want to do
this
File.Delete(img Path + dummyName);

I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyN ame' because it is
being
used by another process."

Does anyone know what I can do about these issues?

Jan 23 '06 #3
Sorry forgot to mention. You cannot manipulate an image at client side,
therefore you need to save the image at server in order to resize it. And
for the delete problem, dispose the Graphics and Rectange object that you
have created before deleting the image.

graphicOrig.Dis pose();
rectOrig.Dispos e();

Zeeshan.
http://zishu.blogspot.com

"benoit" <be****@discuss ions.microsoft. com> wrote in message
news:D1******** *************** ***********@mic rosoft.com...
Hi,

I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile) that
I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documen ts and
Settings\29\Mij n documenten\SubF olderFolder\Img Name.jpg"), I keep getting
a
'FileNotFoundEx ception'. That doesn't happen when I get the SourceFile
from
"C:\Folder\imgN ame".

What can I do about this ?

Actually I found a workaround, but this gives me an error as well....

I can save the PostedFile like this
PostedFile.Save As(imgPath + "DummyName" );

After which I can do these steps without any problem

System.Drawing. Image srcImage =
System.Drawing. Image.FromFile( imgPath + DummyName);

Graphics graphicOrig = Graphics.FromIm age(srcImage);
graphicOrig.Com positingQuality =
CompositingQual ity.HighQuality ;
graphicOrig.Smo othingMode = SmoothingMode.A ntiAlias;
graphicOrig.Int erpolationMode =
InterpolationMo de.HighQualityB icubic;

Rectangle rectOrig = new Rectangle();
graphicOrig.Dra wImage(srcImage , rectOrig);
srcImage.Save(N ewFileName, ImageFormat.Jpe g);

srcImage.Dispos e();

The final srcImage is perfect, and everything I need but when I want to do
this
File.Delete(img Path + dummyName);

I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyN ame' because it is
being
used by another process."

Does anyone know what I can do about these issues?

Jan 23 '06 #4
thanks
it worked !

"Zeeshan Muhammad" wrote:
Sorry forgot to mention. You cannot manipulate an image at client side,
therefore you need to save the image at server in order to resize it. And
for the delete problem, dispose the Graphics and Rectange object that you
have created before deleting the image.

graphicOrig.Dis pose();
rectOrig.Dispos e();

Zeeshan.
http://zishu.blogspot.com

"benoit" <be****@discuss ions.microsoft. com> wrote in message
news:D1******** *************** ***********@mic rosoft.com...
Hi,

I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile) that
I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documen ts and
Settings\29\Mij n documenten\SubF olderFolder\Img Name.jpg"), I keep getting
a
'FileNotFoundEx ception'. That doesn't happen when I get the SourceFile
from
"C:\Folder\imgN ame".

What can I do about this ?

Actually I found a workaround, but this gives me an error as well....

I can save the PostedFile like this
PostedFile.Save As(imgPath + "DummyName" );

After which I can do these steps without any problem

System.Drawing. Image srcImage =
System.Drawing. Image.FromFile( imgPath + DummyName);

Graphics graphicOrig = Graphics.FromIm age(srcImage);
graphicOrig.Com positingQuality =
CompositingQual ity.HighQuality ;
graphicOrig.Smo othingMode = SmoothingMode.A ntiAlias;
graphicOrig.Int erpolationMode =
InterpolationMo de.HighQualityB icubic;

Rectangle rectOrig = new Rectangle();
graphicOrig.Dra wImage(srcImage , rectOrig);
srcImage.Save(N ewFileName, ImageFormat.Jpe g);

srcImage.Dispos e();

The final srcImage is perfect, and everything I need but when I want to do
this
File.Delete(img Path + dummyName);

I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyN ame' because it is
being
used by another process."

Does anyone know what I can do about these issues?


Jan 23 '06 #5
thanks
it worked !

"Daniel Fisher(lennybac on)" wrote:
Try also

graphicOrig.Dis pose();

--Daniel
http://staff.newtelligence.com/danielf/


-----Original Message-----
From: benoit [mailto:be****@d iscussions.micr osoft.com]
Posted At: Monday, January 23, 2006 12:21 PM
Posted To: microsoft.publi c.dotnet.framew ork.aspnet
Conversation: System.drawing. image
Subject: System.drawing. image

Hi,

I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile)
that I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documen ts and
Settings\29\Mij n documenten\SubF olderFolder\Img Name.jpg"), I keep
getting a
'FileNotFoundEx ception'. That doesn't happen when I get the SourceFile
from
"C:\Folder\imgN ame".

What can I do about this ?

Actually I found a workaround, but this gives me an error as well....

I can save the PostedFile like this
PostedFile.Save As(imgPath + "DummyName" );

After which I can do these steps without any problem

System.Drawing. Image srcImage =
System.Drawing. Image.FromFile( imgPath + DummyName);

Graphics graphicOrig = Graphics.FromIm age(srcImage);
graphicOrig.Com positingQuality =
CompositingQual ity.HighQuality ;
graphicOrig.Smo othingMode = SmoothingMode.A ntiAlias;
graphicOrig.Int erpolationMode =
InterpolationMo de.HighQualityB icubic;

Rectangle rectOrig = new Rectangle();
graphicOrig.Dra wImage(srcImage , rectOrig);
srcImage.Save(N ewFileName, ImageFormat.Jpe g);

srcImage.Dispos e();

The final srcImage is perfect, and everything I need but when I want to
do
this
File.Delete(img Path + dummyName);

I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyN ame' because it is
being
used by another process."

Does anyone know what I can do about these issues?

Jan 23 '06 #6

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

Similar topics

1
2397
by: news.microsoft.com | last post by:
Hello group, My goal is to attach an image over another image. Top image should be transparent so the back image is visible through the top one. Bellow is a test code in VB.NET. You need to create a form, a button (Button1) and an Picture Box (picBox). "watermark.jpg" is any jpg image, "beispiel.tif" is a multipage TIFF image with the...
7
14200
by: Toby Mathews | last post by:
Hi, In an ASP.Net application I want to convert open create a FileStream object from a System.Drawing.Image - is this possible? I create an instance of an Image object using the FromFile method, then use the GetThumbnailImage method to create a second Image. This second one is the one I want to get a FileStream from, so that I can then use...
0
1841
by: John via .NET 247 | last post by:
Hi, I'm using the System.Drawing.Bitmap namespace to load an image,and the RotateNoneFlipY method to flip that image before saving.However I have noticed that the saved image appears cropped andhas a large blue area on a particular side, which gets largerevery time the image is flipped again. I'm assuming that this may be due to a lack of...
4
3632
by: Darrel | last post by:
I'm grabbing a file from a file upload form field. This is a 'system.web.httppostedfile' I would like to modify the image (Cropping/scaling) using system.drawing.image. Is there anyway to go from 'system.web.httppostedfile' directly to 'system.drawing.image'? Normally, I'd grab the System.Drawing.Image from a file itself:
3
8921
by: J | last post by:
I tried to inherit 'Shot' class from 'Image' class, only to fail. It gives me the CS0122 error, which says that it can't access 'System.Drawing.Image.Image()'. What am I missing? using System;
5
3358
by: Jerry J | last post by:
I want to use the System.Drawing.Image class. According to the help file, this is an abstract base class. Because it is supposedly abstract, I created another class that inherits from it. However, when I did this I got the following error: 'System.Drawing.Image.Image()' is inaccessible due to its protection level Looking at other online...
3
3997
by: forest demon | last post by:
for example, let's say I do something like, System.Diagnostics.Process.Start("notepad.exe","sample.txt"); if the user does a SaveAs (in notepad), how can i capture the path that the user selects? thanks...
3
6423
by: Dave Keen | last post by:
Hi all. Hope you can help me. This should be easy but I can't make this work. In brief I am building a page of thumbnails using images held in a SQLServer 2000 database. I do this by creating imagebuttons which point to a dummy page that takes the image and displays it via response. All works fine if I use explicit paths to a file...
1
7825
by: mfunkmann | last post by:
Hi, I recently got an error and I don't know how to fix it: Error 1 'System.Data.DataColumn' does not contain a definition for 'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO I am note sure what to do because all propertiers work, except the System.Data.DataColumn.. I didn't write any code by hand and used the visual studio...
2
2315
by: ThatsIT.net.au | last post by:
I have this code that writes a pie chart in a asp.net page, but I want to use it in a server control. When I try I get a error on the last line "Response.OutputStream" Obviously there is no response object but how do I write it to screen? Dim objBitmap As New System.Drawing.Bitmap(400, 440) Dim objGraphics As System.Drawing.Graphics...
0
8176
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8191
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5699
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5370
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3816
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1426
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1154
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.