G
Guest
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:\Documents and
Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting a
'FileNotFoundException'. That doesn't happen when I get the SourceFile from
"C:\Folder\imgName".
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.SaveAs(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.FromImage(srcImage);
graphicOrig.CompositingQuality = CompositingQuality.HighQuality;
graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
graphicOrig.InterpolationMode =
InterpolationMode.HighQualityBicubic;
Rectangle rectOrig = new Rectangle();
graphicOrig.DrawImage(srcImage, rectOrig);
srcImage.Save(NewFileName, ImageFormat.Jpeg);
srcImage.Dispose();
The final srcImage is perfect, and everything I need but when I want to do
this
File.Delete(imgPath + dummyName);
I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyName' because it is being
used by another process."
Does anyone know what I can do about these issues?
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:\Documents and
Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting a
'FileNotFoundException'. That doesn't happen when I get the SourceFile from
"C:\Folder\imgName".
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.SaveAs(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.FromImage(srcImage);
graphicOrig.CompositingQuality = CompositingQuality.HighQuality;
graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
graphicOrig.InterpolationMode =
InterpolationMode.HighQualityBicubic;
Rectangle rectOrig = new Rectangle();
graphicOrig.DrawImage(srcImage, rectOrig);
srcImage.Save(NewFileName, ImageFormat.Jpeg);
srcImage.Dispose();
The final srcImage is perfect, and everything I need but when I want to do
this
File.Delete(imgPath + dummyName);
I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyName' because it is being
used by another process."
Does anyone know what I can do about these issues?