Click here to Skip to main content
14,937,943 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
Hi every one

I wrote program in c# get details about files to compare them later

I have Listview control with 6 column
I an using the following code to add items to listview

but I need to group items according to column 6 values

C#
var items = from f in Files_pathes_hash_Dup
                        select new ListViewItem(
                            new string[] {
                            new System.IO.FileInfo(f).Name, // Name
                            new System.IO.FileInfo(f).FullName, // Directory
                            new System.IO.FileInfo(f).CreationTime.ToString(), // Date Modified
                            new System.IO.FileInfo(f).Length.ToString(),
                            new System.IO.FileInfo(f).Extension,
                            f});
            listView_Files.BeginUpdate();
            listView_Files.Items.AddRange(items.ToArray());
            listView_Files.EndUpdate();


how can I do that without specified group name before adding each items
because I have huge number of Items and I that way it will take long time


Thank you all
Posted
Comments
BillWoodruff 7-Dec-13 4:41am
   
Where do your group names come from, then ?

1 solution

Try:
C#
var items = from fi in
                 (from f in files
                  select new FileInfo(f))
             select new string[] {
                 fi.Name, // Name
                 fi.FullName, // Directory
                 fi.CreationTime.ToString(), // Date Modified
                 fi.Length.ToString(),
                 fi.Extension };
You shouldn't need the original path at teh end, since it is already there as the FullName.
   
Comments
dabbourabd 7-Dec-13 12:52pm
   
thank you for replay
in my code the final value is function to get hash code for the file
and that not my problem
my question is how can I grouping items according to hash code????


var items = from f in Files_pathes_hash_Dup
select new ListViewItem(
new string[] {
new System.IO.FileInfo(f).Name, // Name
new System.IO.FileInfo(f).FullName, // Directory
new System.IO.FileInfo(f).CreationTime.ToString(), // Date Modified
new System.IO.FileInfo(f).Length.ToString(),
new System.IO.FileInfo(f).Extension,
get_hash(f)});
listView_Files.BeginUpdate();
listView_Files.Items.AddRange(items.ToArray());
listView_Files.EndUpdate();

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900