|
-
August 2nd, 2012, 11:18 AM
#1
[RESOLVED] File in use by another process problem
Hello again! I'm having a little problem with a .BackImage property file I want to modify at run time, but can't manage to "release" the file to be able to change what I need. This is what I want to do and what I've tried:
I have a control (ChartArea) with a back image assigned. When values change I want to update the back image of the chart to show the new statistics. I have no problem creating the image file, but the updating only works the first time, when the file was still never assigned as a back image fot the control. After that, I get a "The process can't access the file <path> because it is being used by another process" message.
I've tried the following:
Code:
// Some notes
// ImageArray is a byte[]
// string ChartBackGroundFile points to the path where the file should be written/overwritten (something like "C:\TestApp\TestFile.png")
// WriteAllBytes creates if necessary and overwrites if existing.
ImageArray = GetBackGroundImage(Text, TextColor);
localChartArea.BackImage = "";
Application.DoEvents();
File.WriteAllBytes(ChartBackGroundFile, ImageArray);
localChartArea.BackImage = ChartBackGroundFile;
Since the .BackImage property only accepts a string pointing to a file, I have to actually write the file to hard drive. The problem is that assigning "" to it doesn't seem to release the file. The exception is thrown at WriteAllBytes().
Any ideas?
Thanks a lot,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|