private void ButtonCustomarinfoEditClick(object sender, System.Windows.RoutedEventArgs e)
{
ByteToImage(fileName,bytesOfImage,fileSize);
}
private ImageSource ByteToImage(string fileName, byte[] bytesOfImage, int fileSize)
{
FileStream imageFilestream = new FileStream(fileName, FileMode.Create, FileAccess.Write);
imageFilestream.Write(bytesOfImage, 0, fileSize);
imageFilestream.Flush();
imageFilestream.Close();
imageFilestream.Dispose();
BitmapImage myBitmapImage = new BitmapImage();
myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri(fileName);
myBitmapImage.DecodePixelWidth = 200;
myBitmapImage.EndInit();
return myBitmapImage;
}
When i click ButtonCustomarinfoEdit fist time then it work`s fine. But When i click second time then it throw this exception
Caught: "The process cannot access the file 'C:\20.jpg' because it is being used by another process." (System.IO.IOException)
Exception Message = "The process cannot access the file 'C:\20.jpg' because it is being used by another process.", Exception Type = "System.IO.IOException"