0
메트로 스타일 응용 프로그램에서 간단한 이미지 캐싱을하고 있습니다. 여기 내가 이미 한 일이 있습니다 :어떻게 이미지를 비교할 수 있습니까 (이미지 캐싱)?
private async void GetImage()
{
bool isFolderExisting = true;
bool isFileExisting = true;
StorageFolder storageFolder = null;
StorageFile storageFile = null;
// get screenshots folder
try
{
storageFolder = await ApplicationData.Current.TemporaryFolder.GetFolderAsync("screenshots");
}
catch (System.IO.FileNotFoundException ex)
{
isFolderExisting = false;
}
// if folder doesn't exist, create new one
if (isFolderExisting == false)
storageFolder = await ApplicationData.Current.TemporaryFolder.CreateFolderAsync("screenshots");
// get screenshot
try
{
storageFile = await storageFolder.GetFileAsync(this.LinkId);
//IAsyncAction threadPoolWorkItem = ThreadPool.RunAsync((source) => { updateImage(storageFile); });
}
catch (System.IO.FileNotFoundException ex)
{
isFileExisting = false;
}
// if file doesn't exists, download and save new one
if (isFileExisting == false)
{
var uri = new Uri(WebServiceAddress + "/screenshot/" + this.LinkId, UriKind.Absolute);
var thumbnail = Windows.Storage.Streams.RandomAccessStreamReference.CreateFromUri(uri);
storageFile = await StorageFile.CreateStreamedFileFromUriAsync(this.LinkId, uri, thumbnail);
await storageFile.CopyAsync(storageFolder, storageFile.Name, NameCollisionOption.ReplaceExisting);
}
//this.ImageSource = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appdata:///temp/screenshots/" + this.LinkId));
this.Image = "ms-appdata:///temp/screenshots/" + this.LinkId;
}
이제 이미지를 비교하는 마지막 부분을 처리해야합니다. 임시 폴더에 이미지가 있는지 확인하고 있습니다. 그것이 존재하지 않으면 나는 단지 새로운 것을 다운로드하고있다. 그러나 그것이 존재한다면 나는 그것이 서버와 같은지를 검사 할 필요가있다. 내가 어떻게 그것을 얻을 수 있습니까?