ASP.NET: Open File From URL

asp.netfilenet

In ASP.NET, I have an XML file (within my project) that I would like to deserialize. FileStream objects do not allow you to open a file via URL.

What is the easiest way to open the file so that I can deserialize it?

Best Answer

If the file is within your project you just need to get the physical location of the file. You can use Server.MapPath("/yourfile.txt") to get the phyical location and then open it with a filestream.