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 346591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:11:29+00:00 2026-05-12T11:11:29+00:00

I have a silly, little class FileSystemSize which can be used both as an

  • 0

I have a silly, little class “FileSystemSize” which can be used both as an object and also via public, static methods. The output is similar, but not identical in each case.

The class was intially static, but I added the possibility to initialize it as an object to allow extending with new “convenience methods” in future versions, without the need for a lot of parameter parsing. For example I have GetKBString(), GetMBString(), etc…methods to allow getting the file size conveniently formatted the way I want it (as a string). Internally the class stores the file byte size as a double.

I am a bit confused if this makes sense at all. It seems like I should perhaps split this into a static version and an object version like Microsoft does for Directory and DirectoryInfo. However it just seems easier to me to have this all in one place with a name that can’t be mistaken – it should be clear what FileSystemSize does? Are there any implications for maintenance that I am not anticipating? What’s that smell?

var mypath = @"C:\mypath";

var filesystemsize = new FileSystemSize(mypath);
string kilobytes = filesystemsize.GetKBString();
string megabytes = filesystemsize.GetMBString();
double bytes = filesystemsize.ByteSize;

double staticbytes = FileSystemSize.GetDirectoryBytesSize(new DirectoryInfo(mypath));
double statickilobytes = FileSystemSize.ConvertSize(staticbytes, "KB");
  • 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-12T11:11:30+00:00Added an answer on May 12, 2026 at 11:11 am

    Look at it another way: Why are you putting String/Number/UI formatting methods in your FileSystemSize method?

    While it can be used in respect of files, this is a general piece of functionality that IMHO should be found elsewhere in a well organised library – just as Path functions are not part of the File or Directory classes in .net, I would put the “format a number” methods in a string or maths utils class.

    Separate the responsibilities of your objects and you may find there is no need to mix static and non-static members in cases like this.

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

Sidebar

Related Questions

Consider the following snippet: import java.util.*; public class EqualsOverload { public static void main(String[]
Little silly question, but got stuck for a long time. I have written two
I have a repository class that defines some basic Get/Save/Delete methods. Inside these, I
This is silly, but I haven't found this information. If you have names of
This might be a bit of a silly question but; If I have two
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have you used VS.NET Architect Edition's Application and System diagrams to start designing a
OK, that title is a little unclear, but I can't think of a better
I know this is silly but I can't overcome my curiosity. Is it possible
Is there a way I can have a pad refresh to any window instead

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.