DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: I'm posting a small utility class I wrote for files, in C#  (Read 8,680 times)

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • Participated in NANY Challenge Eight Times
    • Programming School - Deluxe Bonus Medal
    • Programming School - Stage 1 Medal
    • Coding Snacks
    • Military Service Badge - US Army
    • Writer
The attached zip file can be extracted and then the project can be run with Visual Studio (Express or higher editions).
The text file just lists the method signature for the six methods of the static class, and comments them.
As demonstrated in the project, use a "using" statement to reference my namespace.

Demonstrates:
(1) converting file size (number of bytes) to string description, e.g., "7.405 Kb"
(2) reading a file into an array of type byte
(3) writing string data to a filepath
(4) returning number of files in given directory matching a given pattern
(5) returning total size of those pattern-matched files, in bytes
(6) obtaining the directory of the currently executing assembly for a C# console application

See this link: http://www.donationcoder.com/forum/index.php?topic=38081
Win 10 Pro running on a 3.2 GHz CPU and 12 Gb RAM
__________________________________________

Proofreading Service: http://williammillerservices.com/proofreading

« Last Edit: June 02, 2014, 12:01 PM by kyrathaba »

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • Participated in NANY Challenge Eight Times
    • Programming School - Deluxe Bonus Medal
    • Programming School - Stage 1 Medal
    • Coding Snacks
    • Military Service Badge - US Army
    • Writer
Re: I'm posting a small utility class I wrote for files, in C#
« Reply #1 on: June 01, 2014, 09:03 PM »
^ Fixed a couple typos in my previous post.
Win 10 Pro running on a 3.2 GHz CPU and 12 Gb RAM
__________________________________________

Proofreading Service: http://williammillerservices.com/proofreading

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • Participated in NANY Challenge Eight Times
    • Programming School - Deluxe Bonus Medal
    • Programming School - Stage 1 Medal
    • Coding Snacks
    • Military Service Badge - US Army
    • Writer
Re: I'm posting a small utility class I wrote for files, in C#
« Reply #2 on: June 01, 2014, 09:53 PM »
I'm posting a slightly modified version of the project that adds a demonstration of creating a nested subdirectory and writing a file to it. This version does everything the project in the OP does, plus this extra functionality. See attachment.
Win 10 Pro running on a 3.2 GHz CPU and 12 Gb RAM
__________________________________________

Proofreading Service: http://williammillerservices.com/proofreading

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 9,827
    • Participated in NANY Challenge Eight Times
    • Cody Award
Re: I'm posting a small utility class I wrote for files, in C#
« Reply #3 on: June 02, 2014, 07:46 AM »
Wouldn't it be easier to manage and update if you just posted a link to a gist?

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • Participated in NANY Challenge Eight Times
    • Programming School - Deluxe Bonus Medal
    • Programming School - Stage 1 Medal
    • Coding Snacks
    • Military Service Badge - US Army
    • Writer
Re: I'm posting a small utility class I wrote for files, in C#
« Reply #4 on: June 02, 2014, 11:24 AM »
Good idea. I'll look into it.
Win 10 Pro running on a 3.2 GHz CPU and 12 Gb RAM
__________________________________________

Proofreading Service: http://williammillerservices.com/proofreading

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • Participated in NANY Challenge Eight Times
    • Programming School - Deluxe Bonus Medal
    • Programming School - Stage 1 Medal
    • Coding Snacks
    • Military Service Badge - US Army
    • Writer
Win 10 Pro running on a 3.2 GHz CPU and 12 Gb RAM
__________________________________________

Proofreading Service: http://williammillerservices.com/proofreading

Original address: https://www.donationcoder.com/forum/index.php?topic=38075.0