locked
Need Help sending info to .txt file RRS feed

  • Question

  • User-23866969 posted

     I need to send text from 2 text boxes(TextBox1 & TextBox2) to a .txt file on seperate lines.

     

    Please send some code.

     

    Thanks

    Sunday, September 13, 2009 9:27 AM

Answers

  • User187056398 posted

    You can fully specify the namespace:

        System.IO.File.WriteAllLines("C:\Test.txt", Lines) 

     

    Or you can add a using statement:

        using System.IO;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 16, 2009 9:58 PM
  • User-1267218547 posted

     Hi skj09,

    I have put it as it you put it but it says "Name 'File' not declared"

    You need to refer the System.IO namespace.

    http://msdn.microsoft.com/en-us/library/92e05ft3.aspx

    Let me know whether that answers your question, or if I've missed something.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 16, 2009 10:57 PM

All replies

  • User187056398 posted
            Dim Lines() As String =  New String(2) {} 
            Lines(0) = TextBox1.Text
            Lines(1) = TextBox2.Text
     
            File.WriteAllLines("C:\Test.txt", Lines)
    
    


     

    Sunday, September 13, 2009 9:34 AM
  • User-180320890 posted

    you can use XMLHTTP REQUST in Ajax

    for learn you read ajax for dummies 1 chapter otherwise get a reference form http://www.w3schools.com 

    ok please give me vote

    Sunday, September 13, 2009 1:22 PM
  • User-23866969 posted

    I put it in on the Textbox1 bit and it said "End of statment expected."

    Monday, September 14, 2009 2:19 PM
  • User-1267218547 posted

     Hi,

    I put it in on the Textbox1 bit and it said "End of statment expected."

    The statement is syntactically complete, but an additional programming element follows the element that completes the statement. A line terminator is required at the end of every statement.

    To correct this error

    1. Check to see if two different statements have inadvertently been put on the same line.

    2. Insert a line terminator after the element that completes the statement.

    http://msdn.microsoft.com/en-us/library/8dy0ah20(VS.80).aspx
    http://www.google.cn/search?q=End+of+statement+expected

    I hope it is helpful to you.

    Tuesday, September 15, 2009 5:19 AM
  • User-23866969 posted

    1. Dim Lines() As String =  New String(2) {}    
    2. Lines(0) = TextBox1.Text   
    3. Lines(1) = TextBox2.Text   
    4.   
    5. File.WriteAllLines("C:\Test.txt", Lines)  
            Dim Lines() As String =  New String(2) {} 
            Lines(0) = TextBox1.Text
            Lines(1) = TextBox2.Text
     
            File.WriteAllLines("C:\Test.txt", Lines)
    
    


     

     

    I have put it as it you put it but it says "Name 'File' not declared"

     

    Please Help

    Wednesday, September 16, 2009 12:25 PM
  • User187056398 posted

    You can fully specify the namespace:

        System.IO.File.WriteAllLines("C:\Test.txt", Lines) 

     

    Or you can add a using statement:

        using System.IO;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 16, 2009 9:58 PM
  • User-1267218547 posted

     Hi skj09,

    I have put it as it you put it but it says "Name 'File' not declared"

    You need to refer the System.IO namespace.

    http://msdn.microsoft.com/en-us/library/92e05ft3.aspx

    Let me know whether that answers your question, or if I've missed something.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 16, 2009 10:57 PM