Reahreic Reahreic - 3 months ago 10
ASP.NET (C#) Question FileUpload.FileName returns full path in ie when not needed

From what i understand for FileUpload.FileName ruturns the full path while in firefox it returns just the filename. How would i remove the path from the returned string as i just need the html encoded filename.


You can use the Path static class to get the filename.

var fileName = Path.GetFileName(somePath);

And the HttpUtility static class to encode it.

var encoded = HttpUtility.HtmlEncode(fileName);