string GetNormalizedFileName (string fn)
{
if (String.IsNullOrEmpty (fn))
return fn;
// On Linux we don't change \ to / since filenames with \ are valid. We also
// don't remove drive: designator for the same reason.
int len = fn.Length;
if (len >= 3 && fn [1] == ':' && IsFileSystemDirSeparator (fn [2]))
return Path.GetFullPath (fn); // drive-qualified absolute file path
if (len >= 2 && IsFileSystemDirSeparator (fn [0]) && IsFileSystemDirSeparator (fn [1]))
return Path.GetFullPath (fn); // UNC path
HttpContext ctx = context ?? HttpContext.Current;
HttpRequest req = ctx != null ? ctx.Request : null;
if (req != null)
return req.MapPath (fn);
return fn; // Or should we rather throw?
}