 <p>The first one gets filename from the path, but second one will directly give the uploaded filename via upload control <code>PostedFile</code> property whose properties have information about uploaded file like name,size and extension .</p> <p>I suggest to use second one, no need of System.IO as control has property which returns filename.</p>