Results 1 to 6 of 6

Thread: send form results to csv

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 1999
    Location
    London, England
    Posts
    16

    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

  2. #2
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    what is a csv
    Magiaus

    If I helped give me some points.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 1999
    Location
    London, England
    Posts
    16
    comma seperated file - text file

  4. #4
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    Just write to a file then. The folder has to have write permissions and use System.IO.File......... it pretty simple.
    Magiaus

    If I helped give me some points.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Apr 1999
    Location
    London, England
    Posts
    16
    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

  6. #6
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    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();
    Magiaus

    If I helped give me some points.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width