Windows phone 8 从Windows Phone中的本地存储获取uri

Windows phone 8 从Windows Phone中的本地存储获取uri,windows-phone-8,windows-phone,storagefile,Windows Phone 8,Windows Phone,Storagefile,我编写以下代码来保存internet上的一些图像: public static async Task SaveImage(string name, string uri) { var localfolder = ApplicationData.Current.LocalFolder; var client = new HttpClient(); var imageStream = await client.GetStreamAsy

我编写以下代码来保存internet上的一些图像:

    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);
        }
    }
我的问题是,当我试图将这些存储在本地存储中的图像设置为CycleTile时,因为这个类需要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;
CycleTileData-cycleicon=new-CycleTileData();
cycleecon.Title=“fotopantala”;
循环计数=0;
cycleecon.SmallBackgroundImage=新Uri(“/Assets/Tiles/FlipCycleTileSmall.png”,UriKind.RelativeOrAbsolute);
列表图像=新列表();
对于(int i=0;i<9;i++)
{
///尝试。。。
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(路径2,UriKind.RelativeOrAbsolute);
添加(uri);
}
cycleicon.CycleImages=图像;

我错了什么或遗漏了什么?

对于任何与ShellTileData相关的数据结构,您必须使用path2: “isostore:/Shared/ShellContent/*”如果图像不在(只读)InstalledLocation文件夹中

有关更多详细信息,请参阅:

我的代码中有类似的内容:

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(); // <-
var store=IsolatedStorageFile.GetUserStoreForApplication();
如果(!store.DirectoryExists(“Shared/ShellContent”))
{
store.CreateDirectory(“共享/外壳内容”);
}
StorageFolder shellContent=等待Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync(“共享”,CreationCollisionOption.OpenIfExists);
shellContent=等待shellContent.CreateFolderAsync(“shellContent”,CreationCollisionOption.OpenIfExists);
Stream imgin=picture.GetImage();
//从媒体库或其他输入流读取图片流
StorageFile new\u img=wait shellContent.CreateFileAsync(newPictureName);
Stream imgout=wait new_img.OpenStreamForWriteAsync();
imgin.CopyTo(imgout);
imgout.Close();//实际上,这应该是可行的(路径2或路径3)。您是否已使用WP Power Tools或其他Isostorage工具检查下载是否正常?