2013-06-30 3 views
0

나는 인터넷에서 몇 가지 이미지를 저장하려면 다음 코드 쓰기 : 나는 CycleTile 때문에에 로컬 저장소에서 이러한 이미지 저장소를 설정하려고하면윈도우 폰의 로컬 저장에서 URI를 가져

public static async Task SaveImage(string name, string uri) 
    { 
     var localfolder = ApplicationData.Current.LocalFolder; 
     var client = new HttpClient(); 

     var imageStream = await client.GetStreamAsync(uri); //Secuencia de bytes 
     var storageFile = await localfolder.CreateFileAsync(name, CreationCollisionOption.ReplaceExisting); 

     using (Stream outputStream = await storageFile.OpenStreamForWriteAsync()) 
     { 
      await imageStream.CopyToAsync(outputStream); 
     } 
    } 

내 문제를 이 수업에는 Uri가 필요합니다. 나는 여기에 uri를 어떻게 제공해야할지 모르겠습니다. 이것이 내가 가진 것입니다 :

 CycleTileData cycleicon = new CycleTileData(); 
     cycleicon.Title = "Fotopantalla"; 
     cycleicon.Count = 0; 
     cycleicon.SmallBackgroundImage = new Uri("/Assets/Tiles/FlipCycleTileSmall.png", UriKind.RelativeOrAbsolute); 
     List<Uri> images = new List<Uri>(); 

     for (int i = 0; i < 9; i++) 
     { 
      /// tries... 
      string path1 = "ms-appdata:///local/image" + i + ".jpg"; 
      string path2 = "isostore:/Shared/ShellContent/image" + i + ".jpg"; 
      string path3 = "ms-appdata:///Local/Shared/ShellContent/image" + i + ".jpg"; 
      /// 

      Uri uri = new Uri(path2, UriKind.RelativeOrAbsolute); 
      images.Add(uri); 
     } 

     cycleicon.CycleImages = images; 

무엇이 잘못 되었나요?

+0

실제로 작동해야합니다 (경로 2 또는 3). 다운로드가 정상적으로 실행되면 WP Power Tools 또는 다른 Isostorage 도구를 확인 했습니까? – blakharaz

답변

0

ShellTileData 관련 데이터 구조의 경우 이미지가 (읽기 전용) InstalledLocation 폴더에 없으면 path2 : "isostore :/Shared/ShellContent/*"를 사용해야합니다. 자세한 내용은

참조 : http://blogs.msdn.com/b/andy_wigley/archive/2013/04/10/live-apps-creating-custom-tile-and-lock-screen-images.aspx

내가 내 코드에서 비슷한이 : 나는 확실하지 않다

var store = IsolatedStorageFile.GetUserStoreForApplication(); 
if (!store.DirectoryExists("Shared/ShellContent")) 
{ 
    store.CreateDirectory("Shared/ShellContent"); 
} 
StorageFolder shellContent = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync("Shared", CreationCollisionOption.OpenIfExists); 
shellContent = await shellContent.CreateFolderAsync("ShellContent", CreationCollisionOption.OpenIfExists); 

Stream imgin = picture.GetImage(); 
//Picture read stream from Media Library or other input stream 

StorageFile new_img = await shellContent.CreateFileAsync(newPictureName); 
Stream imgout = await new_img.OpenStreamForWriteAsync(); 

imgin.CopyTo(imgout); 

imgout.Close(); // <- necessary in your code or not? 
imgin.Close(); // <- 

을, 당신이 정말로 처음에 Isostore 것은 필요하지만, 작동 여부, 코드를 줄이면서 어리석은 실수를 한 적이 없다면. ;-)

또한 Microsoft의 개발 센터에서 "StandardTileData.BackgroundImage 속성", "Windows Phone 용 데이터"및 "Windows Phone 용 격리 저장소 탐색기 도구 사용 방법"을 살펴보십시오. (마지막은 장치에 저장된 이미지 파일을 보는 방법입니다.)

관련 문제