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"; }
protected void SaveFile_Click(object sender, EventArgs e) { FileInfo fi = GetFile(); if (FileFilters.IsEditable(fi.Name) && FileFilters.IsValidFile(fi.Name)) { try { bool isversioned = FileFilters.IsVersionable(fi.Name); if (isversioned && VersionStore.CurrentVersion(fi) == 0) { VersionStore.VersionFile(fi); } using (StreamWriter sw = new StreamWriter(fi.FullName, false)) { sw.Write(EditBox.Text); sw.Close(); } if (isversioned) { fi = GetFile(); VersionStore.VersionFile(fi); version = VersionStore.CurrentVersion(fi).ToString(); SetVersioning(fi.FullName); } EditMessage.Text = "<strong>" + fi.Name + "</strong> was successfully updated."; EditMessage.Type = StatusType.Success; } catch (Exception ex) { EditMessage.Text = "Your file could not be updated. \n\n Reason: " + ex.Message; EditMessage.Type = StatusType.Error; } } }