I am attempting to reuse the same Stream multiple times. One for resizing the image, and the other for uploading the image. Whilst it does work for resizing the image, it seems to be locking out the other method for uploading the file. I have tried to copy the Stream using Stream.CopyTo(MemoryStream), then using that for uploading, but it still doesn't make a different.
I am opening a Stream using the PhotoChooserTask. I then pass the Stream to a ImageThumbnail method which creates a thumbnail of the image and then saves it to IsolatedStorage as shown below:
public static void SaveThumbnail(Stream imageStream, string fileName, double imageMaxHeight, double imageMaxWidth)
{
var bitmapImage = new BitmapImage();
bitmapImage.SetSource(imageStream);
var resizedImage = new WriteableBitmap(bitmapImage);
using (var isolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
double scaleX = 1;
using (var fileStream = isolatedStorage.CreateFile(fileName))
{
//do stuff for resizing here...
resizedImage.SaveJpeg(fileStream, newWidth1, newHeight1, 0, 100);
}
}
}
At the same time, I am reusing the same Stream from the PhotoChooserTask for uploading the image. EItherway, it seems to be locking eachother out, and no error is being thrown.
Any tips?