-
send form results to csv
I have created a basic web form (with text boxes, option buttons etc) and need to send this information to a csv on the server.
eg i have a text box on the web page called
txtname, txttitle, txtphone
and need them to appear in the csv as:
francis, mr, 55517272
any thoughts?
thanks
Francis
-
-
comma seperated file - text file
-
Just write to a file then. The folder has to have write permissions and use System.IO.File......... it pretty simple.
-
That is my question:
How do I write to a file?
I have textboxes on the form which need to be written to the file.
Thanks
Francis
-
System.IO.File.Open/Create
Returns a stream then you use the stream to write to the file.
Code:
System.IO.Stream stream = System.IO.File.Open(path, System.IO.FileMode.Create, System.IO.FileAccess.Write);
System.IO.Stream stream_b = System.IO.File.Open(path_b, System.IO.FileMode.Create, System.IO.FileAccess.Write);
for(int i = 0; i < upFile.PostedFile.InputStream.Length; i++) //loop through the file from the servers cache
{
stream.WriteByte((byte)upFile.PostedFile.InputStream.ReadByte());
}
byte[] b;
b = System.Text.Encoding.ASCII.GetBytes(txtFileInfo.Text);
stream_b.Write(b, 0, b.Length);
stream.Close();
stream_b.Close();