?
Solved

This should be easy Close this connection System.Drawing.Image.FromFile(

Posted on 2006-11-06
4
Medium Priority
?
537 Views
Last Modified: 2010-08-05
Ok here is the code that I know is causing this issue but I need the code so I need a work around for this

            System.Drawing.Image scottsimg = System.Drawing.Image.FromFile(filelocation + sFilename);
            intThumbHeight = (scottsimg.Height * intThumbWidth) / scottsimg.Width;

Here is the Error
The process cannot access the file 'C:\Documents and Settings\Scott\My Documents\Visual Studio 2005\WebSites\shotdrive\img\178f8f94-8286-4f3c-bc69-c4684020fc4b\2.jpg' because it is being used by another process.


So I assume that when I open that file it is not closing a connection to it. The code that I posted is after I upload an image I need to resize it with out messing up the proportions...
0
Comment
Question by:Scripter25
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
sodalitas earned 2000 total points
ID: 17884390
You need to call scottismg.Dispose() after you are done with it.
0
 
LVL 16

Expert Comment

by:muzzy2003
ID: 17884401
Can you post the code that saves the file just before the snippet you've given us?
0
 
LVL 6

Expert Comment

by:sodalitas
ID: 17884418
Just reread the question and I think I misunderstood.  You are saying that there is code that is creating the file at location filelocation + sFilename and that code is not freeing it up, so when you call FromFile() it cannot access the file?  In that case if you can post your code that is doing the uploading we can see why it's not allowing subsequent access to the file.
0
 

Author Comment

by:Scripter25
ID: 17885832
sodalitas  you were right I did attempt to use this before and it didnt work but when I tried I used it like this
scottsimg.Dispose;
Instead of this
 scottsimg.Dispose();

That is why it didnt work for me the first time.
Thank you for you help on this.....

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

777 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