Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Path does not exist in current context c# .net coding?

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.

like image 821
Sauabhagya Dewangan Avatar asked Jun 29 '17 07:06

Sauabhagya Dewangan


1 Answers

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 !!

like image 132
Laxman Gite Avatar answered Sep 18 '22 13:09

Laxman Gite