C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Get the no of textfiles from a Directory


Posted Date: 07 Oct 2008    Resource Type: Code Snippets    Category: File Operations

Posted By: ravi       Member Level: Gold
Rating:     Points: 10



This code shows how to get number of textfiles from a direcory
In Config file specify source path :

for Ex:

<add key ="Filepath" value="D:\Temp\Test" />

In .CS file:


string strDirectoryPath =ConfigurationManager.AppSettings["Filepath"]; // Retrives the Directory Path

if (Directory.Exists(strDirectoryPath))
{


string[] strArrFiles = Directory.GetFiles(strDirectoryPath, "*.txt"); // Gets all the textfile from the Directory path

if (strArrFiles.Length > 0)
{

label1.Text=strArrFiles.Length + " File(s) found in the Directory!";

}
else
{
label1.Text="No File(s) in the Directory!";
}
}

else
{

label1.Text = strDirectoryPath +" doesnt Exists";
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Get the no of text files from a directory  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Moving file from sourcePath to DestinationPath
Previous Resource: Upload any File Using FileUpload Control ASP.Net
Return to Discussion Resource Index
Post New Resource
Category: File Operations


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

it outsourcing

Contact Us    Privacy Policy    Terms Of Use