Skip to content
JaCraig edited this page Dec 10, 2014 · 1 revision

The file system layer for the library is quite simple to use. There are really only two classes that you will end up using:

  • DirectoryInfo
  • FileInfo

If you are using the System.IO classes of the same name, for most simple functionality you can simply switch to Utilities.IO. These two classes though add a number of features. The first is the ability to specify relative location similar to how you would do this in an MVC app. So:

new FileInfo("~/App_Data/File.txt");

For web apps, this points to the expected location of "base directory for app/App_Data/File.txt". For desktop apps, it's relative to the local executable's directory (or I should say the directory that it is being run from). So it's similar to using "./App_Data/File.txt". You can also do this:

new FileInfo("http://www.google.com");

This will then take all actions that you feed it and point them against the URL that you specify. The system works with HTTP, FTP, local file systems, network file systems, etc. You can also create your own file systems and plug them in with little effort required.

Most of the functionality is pretty basic: Read, Write, Rename, Copy, Delete, etc. Most of those items also take into account basic issues that I ran into using the normal file manipulation objects in C#. For instance if you try to write to a file and the directory that you wish the file to reside doesn't exist, it will automatically create the directory. Similarly if you try to read a file that doesn't exist, it will simply return an empty string. One caveat is that the system should really only be used when you wish to read an entire file as it doesn't currently support block reads.

Clone this wiki locally