Thread: Read / Write X line

  1. #1
    Registered User
    Join Date
    Jan 2020
    Posts
    2

    Read / Write X line

    Hey, I am trying to make program that will count something, for example let's say I want to make All clicks( will take click from button1 and button2) and clicks made on button2 only.

    So for code (just short code, if you want I can add whole code)

    Code:
    string path = @"box.txt";
    if (!File.Exists(path))
    {
        var myFile = File.Create(path);
    myFile.Close();
    }
    else
    {
        counter.Text = File.ReadAllText(path);
    
    
    celk.Text = File.ReadAllText(path);
    }
    
    where counter.Text - textbox for clicks only by button2
    where celk.Text - textbox for all clicks made by both buttons

    but when I give there [celk.Text = File.ReadAllText(path)]

    it won't take second line from file. So if you have any ideas.
    I would like to hear them. Thanks

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,729
    Are you aware that this is a forum for the C programming language, whereas the code that you posted is not written in the C programming language?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jan 2020
    Posts
    2
    Quote Originally Posted by laserlight View Post
    Are you aware that this is a forum for the C programming language, whereas the code that you posted is not written in the C programming language?
    Yeah, I am sorry.
    I should paste it into C# but it was too late. Maybe if someone can move it. :/

  4. #4
    null pointer Structure's Avatar
    Join Date
    May 2019
    Posts
    247
    Although i am familiar with forms I have never programmed in c#, but i would first check if celk is a multiline textbox.

    This might help...
    File.ReadAllText Method (System.IO) | Microsoft Docs


    "without goto we would be wtf'd"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 05-10-2017, 08:30 PM
  2. Replies: 3
    Last Post: 10-28-2015, 02:07 PM
  3. Replies: 21
    Last Post: 08-07-2011, 09:55 PM
  4. Read text file line by line and write lines to other files
    By magische_vogel in forum C Programming
    Replies: 10
    Last Post: 01-23-2011, 10:51 AM
  5. Read command line and write to file or string
    By miiisuuu in forum C Programming
    Replies: 1
    Last Post: 10-21-2007, 11:39 AM

Tags for this Thread