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
As Ak
NA
65
7.6k
How to read the data in the .txt file from 4 different paths
Sep 28 2020 9:01 PM
I need to read the data in the .txt file in the folders from 4 different paths. I've done the code, but it only read the data from the first folder.
How can I read the data in the folder from different paths?
This is my code:
private
void
readData()
{
string
[] Comp =
new
[] {
"A001"
,
"A002"
,
"A003"
,
"A004"
};
string
Comps= Comp[0];
string
Path = $@
"Z:\IT\Shares\PC\PC-{Comp}\SS\Data\{Comp}_DataFile.txt"
;
//read and get details
var data = File
.ReadAllLines(Path)
.Select(x => x.Split(
'='
))
.Where(x => x.Length > 1)
.ToDictionary(x => x[0].Trim(), x => x[1]);
Console.WriteLine(
"Name: {0}"
, data[
"Name"
]);
Console.WriteLine(
"Age: {0}"
, data[
"Age"
]);
}
Reply
Answers (
3
)
zk attendance device check-in and check-out (In Time - Out Time)
getting error in list while displaying data in a single view