public override Task <string[]> ListFolderNames(string path) { return(TaskEx.Run(() => { return FileUtils.WithStorage(storage => { return storage.GetDirectoryNames(EnsureEndsWithSlashStar(path)); }); })); }
private IEnumerable <string> ListStorageItemPaths(Func <IsolatedStorageFile, Func <string, string[]> > storageFunc, string path, bool recursive = false) { return(FileUtils.WithStorage(s => { var subItemNames = storageFunc(s)(EnsureEndsWithSlashStar(path)); var paths = subItemNames.Select(name => path + "/" + name).ToList(); if (recursive) { foreach (var p in paths) { paths.AddRange(ListStorageItemPaths(storageFunc, p, recursive: true)); } } return paths; })); }
/// <summary> /// Note for WP8: System.IO.PathTooLongException: The specified path, /// file name, or both are too long. The fully qualified file name /// must be less than 260 characters, and the directory name must be /// less than 248 characters. /// </summary> /// <param name="absolutePath"></param> /// <returns></returns> public UriInfo UriData(string absolutePath) { return(FileUtils.WithStorage <UriInfo>(s => { if (s.FileExists(absolutePath)) { long size = -1; using (var file = s.OpenFile(absolutePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { size = file.Length; } return new UriInfo(new Uri(absolutePath, UriKind.Relative), (ulong)size); } else { return null; } })); }
public IEnumerable <string> ListFilePaths(string folderPath, bool recursive = false) { return(FileUtils.WithStorage(s => { return ListFilePaths(s, folderPath, recursive); })); }
public override Task Delete(string relativePath) { FileUtils.WithStorage(s => s.DeleteFile(relativePath)); return(AsyncTasks.Noop()); }