Blog Archives

Change ReadOnly File Attribute in C#

Keep in mind when deleting files from code the typical override allowing users to delete anything in their path, whether it is marked readonly or not, will prevent your IO process from continuing and throw a nice little generic “access denied” error.

To resolve this, simply remove the readonly attribute on the file prior to deletion.

     if (File.GetAttributes(fullfilename) == FileAttributes.ReadOnly)
                        File.SetAttributes(fullfilename, FileAttributes.Normal);


Alternatively, using FileSystemInfo (unmodified courtesy of Ken White):

private static void DeleteFileSystemInfo(FileSystemInfo fsi)
    fsi.Attributes = FileAttributes.Normal;
    var di = fsi as DirectoryInfo;

    if (di != null)
        foreach (var dirInfo in di.GetFileSystemInfos())


Wordpress (Imran Akram),
StackOverflow (Ken White),


SVN Revision and Source Control

What is revision control, a.k.a source control?
At it’s core, what this term really means is a way for you to track changes that you may make over time to a particular file.

Each time you change the file and save/commit the change, it is stored as a transaction so you can easily roll back any changes you made at a later date, or search through the history to see something that may have been previously deleted or functional before recent changes.

Business documents usually contain multiple revisions, and knowing if you have the latest copy of a document floating around can be a headache if it changes frequently and the only form of distribution in your organization is email.

Source control will allow you to store all changes from multiple people in a single location, with intact historical reference to each change that is made.

Some source control systems are very popular, such as Microsoft VSS, TFS, SVN and CVS, however, many alternatives exist. There even exists a wikipedia page dedicated to listing a comparative chart of many different types.

After using many of these varieties, I have come to the conclusion that TFS and SVN are roughly equivalent in terms of enterprise scalability and functionality, and also the best overall solutions for development teams IMO. (I may post the proof and comparisons at a later date, too much for this post).

Right out of the box, SVN may not seem like much. To achieve the same functionality you get in a complete TFS installation, alot of configuration and installation must be done, but the end result is much easier to use in an SVN environment.

My recommended setup for SVN on Windows is as follows:
Tortoise SVN,
Ankh SVN,
Subversion Edge (SVN CLI),
SVN Notifier,
Good .Net API Reference,

Tortoise is a good tool for browsing the SVN repository and keeping your local folders in sync. Ankh is a Visual Studio plugin which allows for easy syncing directly from your IDE which is a nice feature esp. if migrating from a MS source control variant. Collabnet Subversion Edge is a good lightweight CLI if you are curious on all of the options available in SVN, or need to script something out automated. SVN Notifier is a good little utility that runs as a service and notifies you when updates occur from other team members. It also serves to automatically keep your files in sync as they are updated.

Wikipedia, “Comparison of revision control software”,
Wikipedia, “Revision Control”,
Wikipedia, “Apache Subversion”,
Wikipedia, “Microsoft Visual Source Safe”,
Wikipedia,”Concurrent Versions System”,
Wikipedia, “Team Foundation Server”,

URL Encode in .Net

C#: (ASP .Net)


C#: (Client/Server Environment)


MSDN, WebUtility Class
MSDN, Uri Class
MSDN blogs,