Проблема в том, что я не могу преобразовать картинку в байт [] и наоборот.
При загрузке картинки с сервера - это уже байтовый массив.Таким образом, вы можете сохранить его с помощью следующего кода:
IsolatedStorageFile Store = IsolatedStorageFile.GetUserStoreForApplication()
IsolatedStorageFileStream filestream = new IsolatedStorageFileStream(Path, FileMode.Create, FileAccess.Write, Store);
int bytesRead = 0;
byte[] buffer = new byte[Int16.MaxValue];
do
{
bytesRead = serverStream.Read(buffer, 0, Int16.MaxValue);
filestream.Write((buffer, 0, bytesRead);
}
while (bytesRead > 0);
stream.Close();
Для загрузки изображения из IsoStore используйте:
if (IsolatedStorageFile.GetUserStoreForApplication().FileExists(Path))
{
BitmapImage Image = new BitmapImage();
using (IsolatedStorageFile Store = IsolatedStorageFile.GetUserStoreForApplication())
{
IsolatedStorageFileStream Stream = new IsolatedStorageFileStream(Path, FileMode.Open, FileAccess.Read, Store);
if (Stream.Length > 0)
{
Image.SetSource(Stream);
}
Stream.Close();
}
return Image;
}