private bool CopyFile(string domain, string source, string target, bool logging = true) { var targetFile = FileHelper.Combine(target, Path.GetFileName(source)); CurrentFile = targetFile; try { var root = XDocument.Parse(client.DownloadString( string.Format("http://{0}/Api/Details/{1}", domain, source))).Root; if (root.GetAttributeValue("status") != "ok") { throw new ExternalException(root.GetAttributeValue("message")); } Save(); Program.OfflineDownload(string.Format("http://{0}/Download/{1}", domain, source), target, client); var file = root.Element("file"); FileHelper.SetDefaultMime(FileHelper.GetDataFilePath(targetFile), file.GetAttributeValue("mime")); ProcessedFileCount++; ProcessedFileLength += file.GetAttributeValue <long>("size"); Save(); return(true); } catch (Exception exc) { if (logging) { ErrorMessage += string.Format("复制 /{0} 时发生了错误:{2}{1}{2}", target, exc.GetMessage(), Environment.NewLine); Save(); } return(false); } }
protected void ModifyMime(object sender, EventArgs e) { if (!CurrentUser.OperateFiles) { Response.StatusCode = 401; return; } FileHelper.SetDefaultMime(FileHelper.GetDataFilePath(RelativePath), Hidden.Value.UrlDecode()); Response.Redirect(Request.RawUrl); }