protected void DeleteFile_Click(object sender, EventArgs e) { FileInfo file = GetFile(); if (FileFilters.IsDeletable(file.Name)) { try { file.Delete(); ActionMessage.Text = "The file " + file.Name + " was deleted"; ActionMessage.Type = StatusType.Success; DownloadButton.Visible = false; EditButton.Visible = false; DeleteButton.Visible = false; } catch (Exception ex) { Log.Error("FileBrowser", "The file {0} could not be deleted\n\nReason: {1}", file.FullName, ex.Message); ActionMessage.Text = "The file " + file.Name + " could not be deleted"; ActionMessage.Type = StatusType.Error; } } }
private void SetFileDetails(FileInfo fi) { FileViews.SetActiveView(FileDetails); FileDetailsLastModified.Text = fi.LastWriteTime.ToLongDateString() + " " + fi.LastWriteTime.ToShortTimeString(); if (FileFilters.IsLinkable(fi.Name)) { FileDetailsName.Text = fi.Name; FileDetailsName.NavigateUrl = "~/" + (Request.QueryString["path"] ?? "") + "/" + fi.Name; } else { FileDetailsName.Visible = false; FileDetailsText.Text = fi.Name; } DownloadButton.Visible = FileFilters.IsDownloadable(fi.Name); EditButton.Visible = FileFilters.IsEditable(fi.Name); DeleteButton.Visible = FileFilters.IsDeletable(fi.Name); if (fi.Extension == ".dll") { Assembly assembly = Assembly.LoadFile(fi.FullName); FileDetailsAssemblyVersion.Text = assembly.GetName().Version.ToString(); } else { assemblyLI.Visible = false; } if (FileFilters.IsVersionable(fi.Name)) { FileDetailsRevision.Text = (VersionStore.CurrentVersion(fi) == 0 ? 1 : VersionStore.CurrentVersion(fi)).ToString(); } else { FileDetailsRevision.Text = "n.a."; revsionLI.Visible = false; } FileDetailsSize.Text = fi.Length.ToString("0,0") + " kB"; }