Getting folder name from drive and Getting file name from folder in C#

December 3, 2009 at 5:55 am Leave a comment

// Getting foldername from a deive
List<string> flist = new List<string>();
DirectoryInfo fdInfo = new DirectoryInfo(@”Z:\”);
DirectoryInfo[] sdinfo = dInfo.GetDirectories();
TextWriter ftw = new StreamWriter(“folderinfo.txt”);
foreach (DirectoryInfo subd in sdinfo)
{
ftw.WriteLine(subd.Name);
}
ftw.Flush();
ftw.Close();

// Getting filename from a folder
List<string> list = new List<string>();
DirectoryInfo dInfo = new DirectoryInfo(@”Z:\”);
FileInfo[] FilesList = dInfo.GetFiles();
TextWriter tw = new StreamWriter(“fileName.txt”);
foreach (FileInfo fi in FilesList)
{
tw.WriteLine(fi.Name);
}
tw.Flush();
tw.Close();

Advertisement

Entry filed under: C#. Tags: , , , , .

Password Generator Page Hit counter asp.net,c#

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

December 2009
M T W T F S S
« Nov   Mar »
 123456
78910111213
14151617181920
21222324252627
28293031  

Follow

Get every new post delivered to your Inbox.