public string[] GetFiles(string path)
 {
     if (path == null)
     {
         throw new ArgumentNullException();
     }
     if (string.IsNullOrWhiteSpace(path))
     {
         throw new ArgumentException("Path is empty");
     }
     try
     {
         IAsyncOperation <IReadOnlyList <StorageFile> > filesAsync = NETFXCOREIOService.GetDirectoryForPath(path).GetFilesAsync();
         WindowsRuntimeSystemExtensions.AsTask <IReadOnlyList <StorageFile> >(filesAsync).Wait();
         IReadOnlyList <StorageFile> results = filesAsync.GetResults();
         List <string> list = new List <string>(Enumerable.Count <StorageFile>((IEnumerable <StorageFile>)results));
         foreach (StorageFile storageFile in (IEnumerable <StorageFile>)results)
         {
             list.Add(storageFile.Path);
         }
         return(list.ToArray());
     }
     catch (IOException ex)
     {
         System.Diagnostics.Debug.WriteLine("NETFXCOREIOService.GetFiles: " + ex.Message + "\n" + ex.StackTrace);
         throw;
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("NETFXCOREIOService.GetFiles: " + ex.Message + "\n" + ex.StackTrace);
         throw new IOException(ex.Message, ex);
     }
 }
 public bool DirectoryExists(string path)
 {
     try
     {
         return(NETFXCOREIOService.GetDirectoryForPath(path) != null);
     }
     catch
     {
         return(false);
     }
 }
        public void DirectoryCreate(string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException();
            }
            if (string.IsNullOrWhiteSpace(path))
            {
                throw new ArgumentNullException("Path is empty");
            }
            StorageFolder folder = (StorageFolder)null;

            path = path.Replace('/', '\\');
            string         path1 = path;
            Stack <string> stack = new Stack <string>();

            do
            {
                try
                {
                    folder = NETFXCOREIOService.GetDirectoryForPath(path1);
                    break;
                }
                catch
                {
                    int length = path1.LastIndexOf('\\');
                    if (length < 0)
                    {
                        path1 = (string)null;
                    }
                    else
                    {
                        stack.Push(path1.Substring(length + 1));
                        path1 = path1.Substring(0, length);
                    }
                }
            }while (path1 != null);
            if (path1 == null)
            {
                System.Diagnostics.Debug.WriteLine("NETFXCOREIOService.DirectoryCreate: Could not find any part of the path: " + path);
                throw new IOException("Could not find any part of the path: " + path);
            }
            try
            {
                while (stack.Count > 0)
                {
                    string desiredName = stack.Pop();
                    if (string.IsNullOrWhiteSpace(desiredName) && stack.Count > 0)
                    {
                        throw new ArgumentNullException("Empty directory name in the path");
                    }
                    IAsyncOperation <StorageFolder> folderAsync = folder.CreateFolderAsync(desiredName);
                    WindowsRuntimeSystemExtensions.AsTask <StorageFolder>(folderAsync).Wait();
                    folder = folderAsync.GetResults();
                }
            }
            catch (IOException ex)
            {
                System.Diagnostics.Debug.WriteLine("NETFXCOREIOService.DirectoryCreate: " + ex.Message + "\n" + ex.StackTrace);
                throw;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("NETFXCOREIOService.DirectoryCreate: " + ex.Message + "\n" + ex.StackTrace);
                throw new IOException(ex.Message, ex);
            }
        }