locked
Writing form results to a TXT file on server RRS feed

  • Question

  • Hi,

    I’m trying to create a form that receives data from one or two text boxes and send that data to a text file on the server.
    I’m using the Web Server that comes with Windows 10 Pro.

    How do I get the form results to be written to a text file in the server?

    Thanks in advance

    • Moved by Stanly Fan Wednesday, August 16, 2017 7:56 AM from windows forms
    Wednesday, August 9, 2017 11:35 AM

All replies

  • Hi CNT,

    Which technology do you use to achieve this purpose? According to your description, maybe it is a web application?

    This forum is discussing and talking about Windows Forms, so if you use Winform and want to write to a text file, you can refer to the following code:

            private void button1_Click(object sender, EventArgs e)
            {
                string[] lines = { textBox1.Text,textBox2.Text };
                System.IO.File.WriteAllLines(@"D:\Test\WriteLines.txt", lines);
            }

    Best Regards,

    Stanly


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Stanly Fan Saturday, August 12, 2017 4:29 AM
    Thursday, August 10, 2017 2:59 AM
  • Hi,

    One aditional question, this code should be placed in asp file correct?

    And in the htm file where the form is i should use someting like this:

    <FORM METHOD="POST" ACTION="mypage.asp" name="Form1">

    assuming the asp page is mypage.asp

    Is this correct?

    Monday, August 14, 2017 1:25 PM
  • Hi,

    The code is C# code that should be placed in the .cs file, and according to your description, your issue is more related about ASP.NET application. And this forum is discussing and asking questions about the Windows Form and ClickOnce, it will be more appropriate to ask your question at ASP.NET FORUM.
    Thank you for your understanding.

    Regards,

    Stanly


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, August 15, 2017 5:29 AM