Reahreic Reahreic - 1 year ago 77
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.

Answer Source

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);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download