Results 1 to 3 of 3

Thread: truncating a file... whats the right way

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    truncating a file... whats the right way

    I have a log file and I want to make sure it doesn grow bigger than a certain size. I open it with the FileStream class and just call the FileStream.SetLength method... am I on the right track? because I dont know if SetLength is made for that purpose or not
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by MrPolite
    I have a log file and I want to make sure it doesn grow bigger than a certain size. I open it with the FileStream class and just call the FileStream.SetLength method... am I on the right track? because I dont know if SetLength is made for that purpose or not
    I don't think this method works this way . I imagine , it set the length of the stream to be written at once (not the length of the file) not sure though .

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    as a workaround this , check for file size if bigger than the size you want it to be , don't write , otherwise write and check again .

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