Tags: c-sharp

Programmatically modifying file permissions in .NET

For one reason or another, somewhere down the line, you’re probably going to want to modify a file’s access permissions from your code. Maybe your users have a nasty habit of overwriting them, or you want to ensure that newly-created files are given a specific permission mask. Whatever the reason, the following C# code example shows how to modify a file’s access permissions using the System.Security.Principal and System.Security.AccessControl namespaces. Read More →

Currency Field Validator for Sitecore CMS

This StandardValidator extension will determine whether or not a given field value passes for currency. In order to do so, it must meet the following requirements:

  1. It must pass decimal.TryParse()
  2. It must not have more than 2 digits past the decimal point

Obviously, this does not fit all international systems—however, in my case, it works for my project (which does not require localization). The code could easily be customized to accommodate additional formats. Read More →