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
matthew king
NA
52
0
environmental variable %Username%
Sep 1 2009 4:17 PM
Sir/Ma'am, I was hoping one of you could assist me with what is probably an easy question. I'm using streamreader to search a txt file, and it works great. However, it just dawned on me that this particular txt file is stored on each of my user profiles: C:/Documents and Settings/%USERNAME%/Application Data/CCMT/ccmtlog.txt For the life of me, I can't figure out how to set an environmental variable in c#. I would appreciate your help.. private void button1_Click(object sender, EventArgs e) { string line; // Read the file and display it line by line. System.IO.StreamReader file = new System.IO.StreamReader(@"C:/Documents and Settings/%USERNAME%/Application Data/CCMT/ccmtlog.txt"); while ((line = file.ReadLine()) != null) { Console.WriteLine(line); string[] lineStrings = line.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (lineStrings.Length > 1) { if (lineStrings[0] == textBox1.Text) { textBox3.Text = lineStrings[1]; } } }
Reply
Answers (
1
)
Textbox Validation
bind user input from column to gridview