Why does System.IO.Path.GetExtension crash server?
Posted on 2006-07-04
I have code that looks like this:
<input id="txtFilePath" type="file" style="width:300px;" runat="server" />
then in my ASP.NET 1.1 C# code i have this:
string fileToUploadExtension = System.IO.Path.GetExtension(txtFilePath.Value).ToLower();
What i am trying to do, is get the file extension of the specified text. for exampel, if someone put in "helloWorld.DOC" i would want to get ".DOC"..
however, if someone trys to put in a ZIP file, or a very large PSD file, the web application crashes and i get an IE error that looks like this:
The page cannot be displayed
The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings.
Is there a better way to get the file extension?