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<Tble_Documents> objTble_Documents = new List<Tble_Documents>();
- 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]);
- }