|
-
March 25th, 2011, 11:48 AM
#1
Extra data from textBox. Please help.
Hello, and thank you.
I am trying to read in user defined input from a text box and use that input as a txt file name.
The problem I am having is when I read the text "test" in I am getting
"System.Windows.Forms.TextBox, Text: test"
When I try and write the file test.txt I get the exception "The given path's format is not supported."
The code:
string profileName1 = "C:\\";
char [] profileName2 = new char[profileNameBox.TextLength];
string placeHolder = profileNameBox.ToString();
try
{
StreamWriter writer;
writer = File.CreateText(profileName1 += placeHolder += ".txt");
writer.WriteLine("This works");
writer.Close();
Console.WriteLine("TXT file Created");
}
catch (Exception ex)
{
MessageBox.Show("Exception: " + ex.Message);
}
So Id like to know how I can get ONLY the text value into my variable with out the extra system notation. Thank you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|