locked
Deleted RRS feed

Answers

  • Hi

    Thank you for posting here.

    For your question, you want to solve the error you got.

    I have reproduced your problem, you could try to add two sentences in the right place.

    Code:               

                    writer.WriteLine(justid + "|" + key + "|" + mail);
                    writer.Flush();
                    rids.WriteLine(id);
                    rids.Flush();
                    writer.Close();
                    rids.Close();
                    Console.WriteLine(id);
    


                 

    Best regards,

    Jack


    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.


    Wednesday, April 3, 2019 6:14 AM

All replies

  • Try this:

    public static FileStream fsw = new FileStream( "ids.txt", FileMode.Create, FileAccess.Write, FileShare.ReadWrite );
    public static StreamWriter writer = new StreamWriter( fsw );
     
    . . .
    
    // Reading lines:
     
    using( FileStream fsr = new FileStream( "ids.txt", FileMode.Open, FileAccess.Read, FileShare.ReadWrite ) )
    {
        using( StreamReader reader = new StreamReader( fsr ) )
        {
            string line;
            List<string> lines = new List<string>();
            while( ( line = reader.ReadLine() ) != null ) lines.Add( line );
            int lineno = lines.Count;
     
            // . . .
        }
    }
    

    Tuesday, April 2, 2019 5:39 PM
  • Hi

    Thank you for posting here.

    For your question, you want to solve the error you got.

    I have reproduced your problem, you could try to add two sentences in the right place.

    Code:               

                    writer.WriteLine(justid + "|" + key + "|" + mail);
                    writer.Flush();
                    rids.WriteLine(id);
                    rids.Flush();
                    writer.Close();
                    rids.Close();
                    Console.WriteLine(id);
    


                 

    Best regards,

    Jack


    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.


    Wednesday, April 3, 2019 6:14 AM