Note that sometimes, on shared hosting like GoDaddy, you might not have the permission to create a new FileInfo
object. Yes, believe it.
So I suggest you use this snippet:
string fullPath = /* System.Web.HttpContext.Current. (optional in most cases) */ Request.Url.AbsolutePath;
string fileName = System.IO.Path.GetFileName(fullPath);
Enjoy :-)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…