Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

MvvmCross.Plugins.File.WindowsCommon bug in EnsureFolderExists #111

Open
brentafis opened this issue Jun 2, 2016 · 1 comment
Open

MvvmCross.Plugins.File.WindowsCommon bug in EnsureFolderExists #111

brentafis opened this issue Jun 2, 2016 · 1 comment

Comments

@brentafis
Copy link

A fully specified (rooted) path is not accounted for in EnsureFolderExists on WindowsUWP (which uses the WindowsCommon FileStore plugin). As a result the full path is created as a series of subdirectories off the rootFolder.

For example:
rootFolder = c:\path\to\root
folderToCheck = c:\path\to\root\folder\to\check
EnsureFolderExists(folderToCheck)
--> expected result => c:\path\to\root\folder\to\check
--> actual result => c:\path\to\root\path\to\root\folder\to\check

I have fixed this in a local branch.

@brentafis
Copy link
Author

brentafis commented Jun 2, 2016

Working version that properly accounts for fully specified folderPath parameter.

        public override void EnsureFolderExists(string folderPath)
        {
            if (FolderExists(folderPath))
                return;

            folderPath = ToFullPath(folderPath);
            var rootPath = ToFullPath(string.Empty);
            var subPath = folderPath.Replace(rootPath, string.Empty);

            var storageFolder = StorageFolder.GetFolderFromPathAsync(rootPath).Await();
            CreateFolderAsync(storageFolder, subPath).GetAwaiter().GetResult();
        }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant