File question
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3

Thread: File question

  1. #1
    Join Date
    Jun 2009

    [Solved] File question

    I need to read the first line in a file then delete that line.
    The only way I can think of doing this is reading in the curent file starting at the second line and then over write the file with the new data.
    My question is how do I read in the file from the second line into an array to rewrite the file?
    Or is there a better easyer way?
    Last edited by ron22; November 22nd, 2011 at 11:28 AM.

  2. #2
    Join Date
    Feb 2011
    United States

    Re: File question

    string path = //Path to the file you want to read/modify
    string[] lines = System.IO.File.ReadAllLines(path);
    System.IO.StreamWriter w = new System.IO.StreamWriter(path);
    for(int i = 1; i < lines.length; i++)
    Best Regards,

    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  3. #3
    Join Date
    Jun 2009

    Re: File question

    Thanks I knew it was easy it was late and I was not thinking the best.

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a survey!

HTML5 Development Center