1

나는 다음과 같이 다음을 비트 맵 이미지를 지정 IsolatedStorage에서 이미지 스트림을 얻을려고오류가

The component cannot be found. (Exception from HRESULT: 0x88982F50)

업데이트 블록을 사용하여 제거했지만 여전히 그 행에 도달하면 오류가 발생합니다. 어쩌면 처음에 파일을 잘못 쓰는 것일까 요? 이 파일을 저장하기 위해 무엇을합니까 :

IsolatedStorageFile isolatedStorage = IsolatedStorageFile.GetUserStoreForApplication(); 

if (!isolatedStorage.DirectoryExists("MyImages")) 
{ 
    isolatedStorage.CreateDirectory("MyImages"); 
} 

var filePath = Path.Combine("MyImages", name + ".jpg"); 

using (IsolatedStorageFileStream fileStream = new IsolatedStorageFileStream(filePath, FileMode.Create, isolatedStorage)) 
{ 
    StreamWriter sw = new StreamWriter(fileStream); 
    sw.Write(image); 
    sw.Close(); 
} 
+1

'SetSource'가 콘텐츠를 즉시 또는 나중에로드하는지 기억이 안납니다. 스트림을 폐기하지 않고도 시도해 볼 수 있습니까? ('using' 블록없이) –

+1

HResult는 이미지 파일의 디코더를 찾을 수 없을 때 생성됩니다. BitmapImage가 파일을 읽을 수있는 기회를 갖기 전에 플로어 매트를 흔들어서 파일을 처리하면 확실히 설명 할 수 있습니다. –

+0

@KooKiz 질문을 업데이트했습니다 – user2757047

답변

1

그림을 저장하는 코드가 잘못되었습니다. 실제 이미지가 아닌 image.ToString()의 결과를 작성하고 있습니다. 경험적으로 문자열을 문자열에 쓰려면 StreamWriter을 사용합니다. 이진 데이터를 쓰는 데 절대로 사용하지 마십시오.

using (var isolatedStorage = IsolatedStorageFile.GetUserStoreForApplication()) 
{ 
    using (var fileStream = new IsolatedStorageFileStream(filePath, FileMode.Create, isolatedStorage)) 
    { 
     var bitmap = new WriteableBitmap(image, null); 
     bitmap.SaveJpeg(fileStream, bitmap.PixelWidth, bitmap.PixelHeight, 0, 100); 
    } 
} 
+0

that.is.working : ') – user2757047