9

In my c# code when I used Path.GetExtension , It is showing "Path does not exist in current context". Seems libraries for Path does not exist in current application. But I searched and found Path class defined in System.IO and System.IO is by default part of our application. After included System.IO the error exist.

1 Answers1

13

You need to add namespace

using System.IO;

And your path should be :

string str= Path.GetExtension(FileUpload1.PostedFile.FileName);

Second way :

string str= System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName);

Then it will work.

Cheers !!

Laxman Gite
  • 2,248
  • 2
  • 15
  • 23