Umbraco Razor C# to List Documents from a Particular Folder, List the File Sizes to 2 Decimail Pace, and Date of the Umbraco Files

The Script Below:

1) Lists the Files in  a folder Chosen from the Media Pickers
2) Converts / Parses the umbracoBytes to KBS and MB
3) Rounds the Umbraco File Size to 2 Decimal Paces
4) Formats the Razor Umbraco Date for Output
5) Writes out the Size of the Files in KBs
6) Writes out the formated Fate
3) Writes out a description of the document.

  foreach (var folder in imageFolder.Children)
double KBsize = 0;
double MBsize = 0;
double FileSize = Int32.Parse(@folder.umbracoBytes);

KBsize = FileSize / 1024;
MBsize = FileSize / 1048576;

// Round KB Size to 2 Decimal Points
KBsize = Math.Round(KBsize, 2);

// Format Date
string outDate = @library.FormatDateTime(@folder.createDate, "dd/MM/yyyy");

  <p>&bull; <a href="@folder.Url">@folder.Name (@folder.umbracoExtension) | File Size:  @KBsize KB | Date Created:  @outDate</a>

  <div class="thinline"> </div>



Popular posts from this blog

Umbraco Razor Sort Nodes Ascending or Descending

Umbraco Razor get Querystring

Create a .NET Contact Form that Gets the Last Url Visited in C# Can also be Used in Umbraco