TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Albin
NA
1
0
Image Control problem
Jan 10 2009 11:00 AM
Im trying to write a image from a database to the hard drive and then read it back to the Image Control.
Im getting the error: The process could not access .........\temp.jpg because it is being used by another process
I have a the same app in Winforms and there its simple just put Picturebox.Image.Dispose before you attempt to write over the old file. But in WPF it won't work. I have spent hours trying to figure this out, tried to dispose a lot of resources and Google. But could not find anything.
I don't want to read the picture to the memory because it uses a lot of it.
If someone could help me it would be appreciated, Thanks
my code is
if (imageStorage.Source != null)
{
imageStorage.Source
=
null
;
}
FileStream
FS1
=
new
FileStream("temp.jpg", FileMode.Create);
byte[]
buff
= (byte[])dRow[1];
FS1.Write(buff, 0, buff.Length);
FS1.Close();
FS1.Dispose();
BitmapImage
image
=
new
BitmapImage();
image.BeginInit();
image.UriSource
=
new
Uri(Directory.GetCurrentDirectory() + "\\temp.jpg");
image.DecodePixelWidth
=
200
;
image.EndInit();
image
imageStorage.Source
= image;
Reply
Answers (
1
)
Filtering a Dataset
Help system for WPF application