John Brush
John Brush

Reputation: 177

StorageFolder GetFolderFromPathAsync Windows Phone 8

Hello i have this code

private async Task SaveImageToIsolatedStorage(Stream stream)
        {

            StorageFolder Datafolder = await ApplicationData.Current.LocalFolder.GetFolderAsync("Data");
            StorageFolder subfolder1 = await Datafolder.GetFolderAsync("subfolder1");
            StorageFolder subfolder2 = await subfolder1 .GetFolderAsync("subfolder2");

            StorageFile file = await subfolder2.CreateFileAsync("test.jpg", CreationCollisionOption.ReplaceExisting);
            using (Stream current = await file.OpenStreamForWriteAsync())
            {
                await stream.CopyToAsync(current);
            }

        }

if i use directly StorageFolder.GetFolderFromPathAsync("Data\subfolder1\subfolder2") receive error

{System.IO.FileNotFoundException: The system cannot find the file specified

how to?

Upvotes: 0

Views: 1421

Answers (2)

John Brush
John Brush

Reputation: 177

ok it work with this code

StorageFolder folder= await ApplicationData.Current.LocalFolder.GetFolderAsync("Data\\subfolder\\subfolder1");

Upvotes: 0

robwirving
robwirving

Reputation: 1798

According to a post on msdn you need to use double slashes:

StorageFolder.GetFolderFromPathAsync("Data\\subfolder1\\subfolder2")

http://social.msdn.microsoft.com/Forums/windowsapps/en-US/2587b868-4f78-47e7-bae1-314b6eb5d9f3/how-do-i-access-a-file-that-is-nested-inside-other-folders?forum=winappswithhtml5

Upvotes: 1

Related Questions