Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3271892
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:46:20+00:00 2026-05-17T18:46:20+00:00

In our customized C# logging system, we use streamWriter = File.CreateText(fileNameStr); to create a

  • 0

In our customized C# logging system, we use streamWriter = File.CreateText(fileNameStr); to create a file and open a stream for write.

Now we want to monitor the file size to see if it reach the max required size. What I did is the following:

  1. create a FileInfo object for about file: currFileInfo = new FileInfo(fileNameStr);
  2. get file size after each write: curFileInfo.Refresh(); fileSize = curFileInfo.Length;
  3. compare the file size with max file size, if bigger, close the current one and create a new file.

I have print out to see how long it will take to refresh the FileInfo, many times it will take about 15msec.

So I am thinking there may be a better way to do this. what’s your suggestion?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:46:20+00:00Added an answer on May 17, 2026 at 6:46 pm

    This should work:

    streamWriter.BaseStream.Position;
    

    This should contain the current position of the stream and if you’re using it for appending only, this should contain the correct file size.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our EPOS system copies data by compressing the database into a zip file, and
We've created a highly customized Joomla 1.5 based site and want our super administrator
In our current project we are providing a PDF download that can be customized
Our team develops distributed winform apps. We use ClickOnce for deployment and are very
Our team is creating a new recruitment workflow system to replace an old one.
We are revamping our product which gets highly customized for each client. Currently we
I have a snippet to create a 'Like' button for our news site: <iframe
Our company is currently writing a GUI automation testing tool for compact framework applications.
Our ASP.NET 3.5 website running on IIS 6 has two teams that are adding
Our dev shop currently uses Visual SourceSafe. We all know how that could end

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.