var fileName = Path.GetFileName(somePath);
和HttpUtility静态类来编码它.
var encoded = HttpUtility.HtmlEncode(fileName);