public void Delete(string remotename) { try { TaggedFileEntry f = GetFile(remotename); //This does not work if the item is in a folder, because it will only be removed from the folder, // even if with the "delete=true" setting //CreateRequest().Delete(new Uri(f.AtomEntry.EditUri.Content + "?delete=true"), f.ETag); //Instead we create the root element id (that is without any folder information), //and delete that instead, that seems to works as desired, fully removing the file Google.Documents.DocumentsRequest req = CreateRequest(); string url = req.BaseUri + "/" + HttpUtility.UrlEncode(f.ResourceId) + "?delete=true"; req.Delete(new Uri(url), f.ETag); //We need to ensure that a LIST will not return the removed file m_files.Remove(remotename); } catch (Google.GData.Client.CaptchaRequiredException cex) { throw new Exception(string.Format(Strings.GoogleDocs.CaptchaRequiredError, CAPTCHA_UNLOCK_URL), cex); } catch (System.IO.FileNotFoundException ex) { throw new FileMissingException(ex); } catch { //We have no idea if the file was removed or not, // so we force a filelist reload m_files = null; throw; } }
private Dictionary <string, TaggedFileEntry> GetFileList() { Google.Documents.Document folder = GetFolder(); Google.Documents.DocumentsRequest req = CreateRequest(); Dictionary <string, TaggedFileEntry> results = new Dictionary <string, TaggedFileEntry>(); foreach (Google.Documents.Document file in req.GetFolderContent(folder).Entries) { if (results.ContainsKey(file.Title)) { throw new Exception(string.Format(Strings.GoogleDocs.DuplicateFilenameFoundError, file.Title, folder.Title)); } string updateUrl = null; foreach (Google.GData.Client.AtomLink x in file.AtomEntry.Links) { if (x.Rel.EndsWith("#resumable-edit-media")) { updateUrl = x.HRef.ToString(); break; } } results.Add(file.Title, new TaggedFileEntry(file.Title, (long)file.QuotaBytesUsed, file.LastViewed, file.Updated, file.ResourceId, file.DocumentEntry.Content.Src.ToString(), updateUrl, file.ETag)); } return(results); }