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 !






Listing Subfolders and Files in a Directory , Using c#


Posted Date: 25 Apr 2008    Resource Type: Code Snippets    Category: File Operations

Posted By: Suresh       Member Level: Silver
Rating:     Points: 7



The following code can be used to list the Subfolders and Files in a Directory.





private void dir_list()

{
string path="D:\\Temp\\"; // Parent Directory
string dirname = TextBox1.Text; // Reading directory name from a textbox in the form
DirectoryInfo dir1=new DirectoryInfo(path+dirname);
DirectoryInfo[] dirar=dir1.GetDirectories();
FileInfo[] filear=dir1.GetFiles();
foreach(DirectoryInfo dir2 in dirar)
{
Response.Write(dir2.Name.ToString());
}
foreach(FileInfo fil2 in filear)
{
Response.Write(fil2.Name.ToString());
}
}







Responses


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

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

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: Directory Create/Check/Delete, Using C#
Previous Resource: How to read a text file and store into a variable
Return to Discussion Resource Index
Post New Resource
Category: File Operations


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use