Abhilash J A

Abhilash J A

  • 533
  • 2.4k
  • 598k

If list contain duplicate value then get total count - C#

Jan 1 2017 9:25 AM
Hello Everyone,
 
I have list items.
 
 
This 3 records contain images, that is image path from database. I want to get total size of the image group by ArchievedName .
 
1st item,
 
 
 
2nd item,
 
 
 
3rd item,
 
 
 
I have tried, 
  1. List<Tble_Documents> objDocumentUserSetup = new List<Tble_Documents>();  
  2.   
  3. bjDocumentUserSetup = objUserSetUp1.AsEnumerable().Select(m => new Tble_Documents()  
  4.                   {  
  5.                       ArchievedName = m.ArchievedName,  
  6.                       UpdatedDate = m.UpdatedDate,  
  7.                       Fullname = m.Fullname,  
  8.                       FilePath = m.FilePath + m.Parent_File_Name + "_" + m.Child_File_Name,  
  9.                       docCount = m.docCount,  
  10.                       FileSize = FormatBytes(new System.IO.FileInfo(m.FilePath + m.Parent_File_Name + "_" + m.Child_File_Name).Length) /*How can do here?*/  
  11.                   }).ToList();  
  1. private static string FormatBytes(long bytes)  
  2.        {  
  3.            string[] Suffix = { "B""KB""MB""GB""TB" };  
  4.            int i;  
  5.            double dblSByte = bytes;  
  6.            for (i = 0; i < Suffix.Length && bytes >= 1024; i++, bytes /= 1024)  
  7.            {  
  8.                dblSByte = bytes / 1024.0;  
  9.            }  
  10.   
  11.            return String.Format("{0:0.##} {1}", dblSByte, Suffix[i]);  
  12.        }  
 Please help me.
 
 

Answers (5)