Hello Everyone,
I have list of items to bind listview wpf. Inside list items there is FileSize = FormatBytes(x.fsize) I want to get total size of FileSize. How can I do that ?
- public UC_ArcMgmt()
- {
- InitializeComponent();
- DMSBusinessLayer service = new DMSBusinessLayer();
- var data = service.GetArchivedList().SelectMany((x) => new[] { new { Fullname = x.Fullname, Id = x.Id, ArchievedName = x.ArchievedName, UpdatedDate = x.UpdatedDate, FileSize = FormatBytes(x.fsize), docCount = x.docCount } }).Distinct()
- GroupBy((x) => x.ArchievedName);
- List
objTble_Documents = new List (); - foreach (var x in data)
- {
- objTble_Documents = x.AsEnumerable().Select(m => new Tble_Documents()
- {
- Fullname = m.Fullname,
- Id = m.Id,
- ArchievedName = m.ArchievedName,
- UpdatedDate = m.UpdatedDate,
- FilePath = m.FileSize,
- docCount = m.docCount
- }).ToList();
- }
- listView1.ItemsSource = objTble_Documents;
- }
- private static string FormatBytes(long bytes)
- {
- string[] Suffix = { "B", "KB", "MB", "GB", "TB" };
- int i;
- double dblSByte = bytes;
- for (i = 0; i < Suffix.Length && bytes >= 1024; i++, bytes /= 1024)
- {
- dblSByte = bytes / 1024.0;
- }
- return String.Format("{0:0.##} {1}", dblSByte, Suffix[i]);
- }


Amit GuptaRank #190 · 12.8K reputationPosted Jan 6, 2017, 8:35 AM EST
Amit GuptaRank #190 · 12.8K reputationPosted Jan 5, 2017, 11:48 AM EST
- long totalFileSize =0;
-
- private static string FormatBytes(long bytes)
- {
- totalFileSize += bytes
- string[] Suffix = { "B", "KB", "MB", "GB", "TB" };
- int i;
- ........
}Amit GuptaRank #190 · 12.8K reputationPosted Jan 6, 2017, 3:13 AM EST
Tapan PatelRank #614 · 3.9K reputationPosted Jan 5, 2017, 12:18 PM EST
Abhilash J ARank #1,243 · 1.4K reputationPosted Jan 5, 2017, 4:59 PM EST
Bikesh SrivastavaRank #109 · 20.3K reputationPosted Jan 6, 2017, 9:27 AM EST
Abhilash J ARank #1,243 · 1.4K reputationPosted Jan 6, 2017, 8:26 AM EST
Abhilash J ARank #1,243 · 1.4K reputationPosted Jan 6, 2017, 9:10 AM EST