topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday December 13, 2024, 1:40 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

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

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
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: https://www.donationcoder.com/forum/index.php?topic=38081
« Last Edit: June 02, 2014, 07:01 AM by kyrathaba »

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
Re: I'm posting a small utility class I wrote for files, in C#
« Reply #1 on: June 01, 2014, 04:03 PM »
^ Fixed a couple typos in my previous post.

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
Re: I'm posting a small utility class I wrote for files, in C#
« Reply #2 on: June 01, 2014, 04: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.

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 9,778
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: I'm posting a small utility class I wrote for files, in C#
« Reply #3 on: June 02, 2014, 02: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
    • View Profile
    • Donate to Member
Re: I'm posting a small utility class I wrote for files, in C#
« Reply #4 on: June 02, 2014, 06:24 AM »
Good idea. I'll look into it.

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member