|
using System.IO;
using System.Web;
namespace WebCRC
{
public static class CRC
{
public static string Content(this System.Web.Mvc.UrlHelper Url, string Path, bool CRC)
{
if (!CRC)
return Url.Content(Path);
string serverPath = HttpContext.Current.Server.MapPath(Path);
byte[] fileContents = File.ReadAllBytes(serverPath);
string result = CRC32.Compute(fileContents).ToString("X");
return Url.Content(Path) + "?crc=" + result;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Paul Reid is the CEO (and still part-time programmer) of Product4Me Corporation, a web site company devoted to helping consumers get the individualized best fit for home theater (and other) products.