Results 1 to 2 of 2

Thread: [RESOLVED] Max File Size

  1. #1

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610

    Resolved [RESOLVED] Max File Size

    Hi All,

    I would like to create a log file for one of my applications so that I can limit the size of the file.

    At the moment I am going to read in the entire file. If the file is larger then the size limit specified. I was add the new line to an array in memory and the write the file to the array in reverse order up to the size limit specified.

    But the performance of my application will suffer if I make a lot of writes to this file.

    Does anyone have a better way of handling this type of file writing?
    This space for rent...

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Max File Size

    I would suggest that when you want to write to the log file you ignore the file size and just use AppendAllText to write. When your app is shutting down, then you could check the file size and trim it if required. That way you aren't reading and trimming over and over while your app is running.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

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



Click Here to Expand Forum to Full Width