0
로컬 디렉토리에 bitmapimages를 저장하고 싶습니다. 그리고 그 코드를 썼습니다. 그러나 알 수없는 오류가 발생하여 컴파일 할 수 없습니다. 오류의 원인과 bitmapImages를 변환하고 저장하는 올바른 방법을 알려주십시오.Windows8에서 bitmapImages를 변환하고 저장하는 방법
void StoreAndGetBitmapImage()
{
BitmapImage image = new BitmapImage(new Uri("ms-appx:///Assets/" + "test.png"));
StorageFile storageFile = ConvertBitmapImageIntoStorageFile(image, "image_name");
StoreStorageFile(storageFile);
BitmapImage resultImage = GetBitmapImage("image_name");
}
StorageFile ConvertBitmapImageIntoStorageFile(BitmapImage bitmapImage,string fileName)
{
StorageFile file = Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(bitmapImage.UriSource).GetResults();
file.RenameAsync(fileName);
return file;
}
void StoreStorageFile(StorageFile storageFile)
{
storageFile.CopyAsync(Windows.Storage.ApplicationData.Current.LocalFolder);
}
BitmapImage GetBitmapImage(string fileName)
{
BitmapImage bitmapImage;
bitmapImage = new BitmapImage();
bitmapImage.UriSource = new Uri(new Uri(
Windows.Storage.ApplicationData.Current.LocalFolder.Path + "\\" +
Windows.Storage.ApplicationData.Current.LocalFolder.Name),
fileName);
return bitmapImage;
}
고맙습니다. 나는이 메소드를 동 기적으로 실행하기를 원하기 때문에 의도적으로 "기다리고있다". – JohnyDgoode
그런 다음 비동기 작업의 반환 값에 대해 Wait()을 호출해야합니다. –
나는 본다! 감사 ! – JohnyDgoode