Get URI for a stored file in StorageFile (WinRT)
Asked Answered
C

1

3

I'm building a metro app, and I'm trying to get a Uri of an Image after saving it in the StorageFile, this is my code:

StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync("samplefile.dat", CreationCollisionOption.ReplaceExisting);

IRandomAccessStream raStream = await file.OpenAsync(FileAccessMode.ReadWrite);
IOutputStream outStream = raStream.GetOutputStreamAt(0);
DataWriter dw = new DataWriter(outStream);
dw.WriteBytes(img); // I'm saving array of bytes
await outStream.FlushAsync();

I read this article:

and it says I can access the stored files using ms-appdata, so i tried this:

Uri uri = new Uri("ms-appdata:///samplefile.dat", UriKind.Absolute);

but it doesnt work

Composure answered 9/5, 2012 at 7:51 Comment(0)
E
12

Assuming it is stored in the Local folder, the URI should be

Uri uri = new Uri("ms-appdata:///local/samplefile.dat");

Note the additional "local" in the middle.

Ermin answered 11/5, 2012 at 16:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.