TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
csharp beginner
NA
38
11.9k
reading files
Jun 23 2014 2:46 AM
I am stuck with a small problem. I need help here .... So, please help me if anybody having a solution for this.
I am having a no of csv files and each file is having two rows. Now what i want is, reading each file and writing the elements of each row from the csv files, into two fixed arrays.
The code i wrote is:
FolderBrowserDialog folder = new FolderBrowserDialog();
if (folder.ShowDialog() == DialogResult.OK)
{
string[] filesGot = Directory.GetFiles(folder.SelectedPath);
try
{
List<string> listA = new List<string>();
List<string> listB = new List<string>();
foreach (string fileRead in filesGot)
{
string[] datalines = File.ReadAllLines(fileRead);
foreach (string line in datalines)
{
string[] mycolumns = line.Split(',');
listA.Add(mycolumns[0]);
listB.Add(mycolumns[1]);
}
}
string[] firstlistA = listA.ToArray();
string[] firstlistB = listB.ToArray();
}
Reply
Answers (
6
)
Automatic Garbage Collection
dealing with zip files in c#