PC Review


Reply
Thread Tools Rate Thread

BUG: System.Drawing.Image.FromFile locks file

 
 
Taiwo
Guest
Posts: n/a
 
      9th Oct 2003

When I use the method "System.Drawing.Image.FromFile(pictureFile)" where
pictureFile is the path to a valid image file, the file is locked even
minutes after the statement executes. This code is in a web service hosted
in IIS on Windows XP. Typically, I have to run IISRESET from the Command
Line to be able to rename the file.

My work around is to use a different method:

Dim fs As FileStream = New FileStream(pictureFile, FileMode.Open,
FileAccess.Read, FileShare.ReadWrite)
dim pic As Image = System.Drawing.Image.FromStream(fs)
fs.Close()
fs = Nothing

With this method, I open the file for Read Shared, use the FromStream
method, and close the file stream immediately.

The VS.NET team here may want to verify this.

---
Taiwo


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Image.FromFile - Locks File Jeff Gaines Microsoft C# .NET 5 18th Sep 2009 09:01 AM
Mirror / rotate image ( System.Drawing.Graphics / System.Drawing.Drawing2D.Matrix) Eduard Witteveen Microsoft C# .NET 3 17th Jul 2006 01:26 PM
FromFile is not a member of the System.Drawing.Image =?Utf-8?B?UEo=?= Microsoft VB .NET 2 7th Sep 2004 07:48 PM
Re: Bitmap.FromFile() method locks file! Vivamex Microsoft Dot NET 0 23rd Jan 2004 11:41 PM
Out of Memory Exception: System.Drawing.Image.FromFile anastasia Microsoft ASP .NET 2 2nd Aug 2003 02:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:17 AM.