Hi,
I'm trying to get my program to write the content of textbox1 into a textfile specified at a particular location. However I get an error when trying to do so.
My code:
protected void btnSave_Click(object sender, EventArgs e)
{
//Write to fileupload location
System.IO.StreamWriter StreamWriter1 = new System.IO.StreamWriter(FileUpload1.PostedFile.FileName);
//Writing text to the file.
StreamWriter1.Write(TextBox1.Text);
//Close the file.
StreamWriter1.Close();
}
Now i've checked the FileUpload1.Postfiled.Filename and it shows as text.txt - rather than the location clearly entered into FileUpload1 which is "C:\\Users\\Name\\Desktop\\test.txt".
If i specify the location it works perfectly, however I want user to first select the file and then save.
Thank you kindly.