realn
realn

Reputation: 1742

Reading From local folder in C#

In C# code, if I refer to a file by just the file name, it's not reading it from the local folder. Instead it refers to c:\windows\system32\inetsrv\ and throws a FileNotFoundException. How do I read from the local folder?

Upvotes: 0

Views: 238

Answers (1)

amit_g
amit_g

Reputation: 31260

You probably are referring to the files in the virtual directory. Use Server.MapPath

filePath = Server.MapPath("~/path/relative/to/site/root/filename")

Upvotes: 2

Related Questions