Click here to Skip to main content
15,900,816 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to read multiple csv files from a folder with different names and these csv's are inside different folders inside that folder. i want to search thesse csv's in different folders of that folders. so plz help me to read the csv from different folder inside that folder. tnx in advance.
Posted

Have a look at the DirectoryInfo class in the System.IO namespace, C# code but simple to convert!

C#
string directoryPath = @"C:\FolderToSearch";
DirectoryInfo dir = new DirectoryInfo(directoryPath);
FileInfo[] files = dir.GetFiles("*.csv", SearchOption.AllDirectories);

foreach (FileInfo file in files)
{
    // However you want to process the CSV file
}
 
Share this answer
 
Comments
Maciej Los 9-Mar-12 11:04am    
My 5 despite of an example in C# ;)
taher ahmed choudhury 11-Mar-12 0:13am    
after putting these code in vb.net it is not showing any csv file in thatt folder
Dim directoryPath As String = Application.StartupPath + "\Input\"
Dim dir As New DirectoryInfo(directoryPath)
Dim files As FileInfo() = dir.GetFiles("*.csv", SearchOption.AllDirectories)

' However you want to process the CSV file
For Each file As FileInfo In files
Next

plz help these are my code
Take a look at: DirectoryInfo.GetFiles method[^] - with an example in VB.NET.
 
Share this answer
 
Comments
ProEnggSoft 9-Mar-12 11:40am    
Good pointer. My 5
Maciej Los 9-Mar-12 13:11pm    
Thank you ;)

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