Count of selection file in C#.net

Posted by Naraayanan under C# on 1/23/2012 | Points: 10 | Views : 2186 | Status : [Member] | Replies : 5
Hi,
How can i count of Selection file in the C#.net? .
For Example :
In my project ,I am using "RegEdit" ,that means Windows Registry.
1) User could select a File/Files from any folders
2) Click on the File.User could view the Count of selection of file in the Folder
Please Help me.

Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/



Responses

Posted by: Hemanthlaxmi on: 1/23/2012 [Member] Starter | Points: 25

Up
0
Down
You can get the Count of the Files in the directory .

Check this Code Snippet
private int file_count = 0;

///
/// Get the file count of a given directory recursively.
///
public void GetDirectoryFileCount(string dir)
{
dir = dir + @"\";
//get all the directories and files inside a directory
String[] all_files=Directory.GetFileSystemEntries(dir);
//loop through all items
foreach(string file in all_files)
{
//check to see if the file is a directory if not increment the count
if(Directory.Exists(file))
{
//recursive call
GetDirectoryFileCount(file);
}
else
{
//increment file count
file_count++;
}
}
}


If this helps you .
Please "Mark as Answer"

Naraayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naraayanan on: 1/23/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
Thanks for your reply. I don't want to no of files in the Folder. I want to Counting of selected files in the folder(@ runtime).
Note:Please understand my question before reply my mail.


Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Naraayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hemanthlaxmi on: 1/24/2012 [Member] Starter | Points: 25

Up
0
Down
Ok.

Pass the selected Folder Path to the method which will give you the Count in run time.

If this helps you .
Please "Mark as Answer"

Naraayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naraayanan on: 1/24/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
Thanks for your reply..

Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Naraayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hemanthlaxmi on: 1/24/2012 [Member] Starter | Points: 25

Up
0
Down
You are welcome.


If this helps you .
Please "Mark as Answer"

If this helps you .
Please "Mark as Answer"

Naraayanan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response