private static Boolean BuildDirectyEntry(BaseDirectoryEntry dirEntry, JsonHelper jh, IStorageProviderService service, IStorageProviderSession session) { // build the file entry part if (!BuildFileEntry(dirEntry, jh)) return false; // now take the content var content = jh.GetListProperty("contents"); if (content.Count == 0) return true; // remove all childs dirEntry.ClearChilds(); // add the childs foreach (var jsonContent in content) { // parse the item var jc = new JsonHelper(); if (!jc.ParseJsonMessage(jsonContent)) continue; // check if we have a directory var isDir = jc.GetBooleanProperty("is_dir"); BaseFileEntry fentry; if (isDir) { fentry = new BaseDirectoryEntry("Name", 0, DateTime.Now, service, session); } else { fentry = new BaseFileEntry("Name", 0, DateTime.Now, service, session); } // build the file attributes BuildFileEntry(fentry, jc); // establish parent child realtionship dirEntry.AddChild(fentry); } // set the length dirEntry.Length = dirEntry.Count; // go ahead return true; }
private void RefreshChildsOfDirectory(IStorageProviderSession session, BaseDirectoryEntry dir) { // get the location String reslocation = GetResourceUrl(session, dir as ICloudFileSystemEntry, null); // ensure that we have a trailing slash reslocation = reslocation.TrimEnd('/'); reslocation = reslocation + "/"; // build the uri Uri resUri = new Uri(reslocation); // convert BaseDir to DirInfo DirectoryInfo dInfo = new DirectoryInfo(resUri.LocalPath); // clear childs dir.ClearChilds(); // get all childs foreach (FileSystemInfo fInfo in dInfo.GetFileSystemInfos()) { BaseFileEntry f = CreateEntryByFileSystemInfo(fInfo, session, dir); dir.AddChild(f); } }