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 GuptaPosted Jan 6, 2017, 1:35 PM
Bikesh SrivastavaPosted Jan 6, 2017, 2:27 PM
Abhilash J APosted Jan 6, 2017, 2:10 PM
Abhilash J APosted Jan 6, 2017, 1:26 PM
Amit GuptaPosted Jan 6, 2017, 8:13 AM
Abhilash J APosted Jan 5, 2017, 9:59 PM
Tapan PatelPosted Jan 5, 2017, 5:18 PM
Amit GuptaPosted Jan 5, 2017, 4:48 PM
- long totalFileSize =0;
-
- private static string FormatBytes(long bytes)
- {
- totalFileSize += bytes
- string[] Suffix = { "B", "KB", "MB", "GB", "TB" };
- int i;
- ........
}