The 'MapPath' method cease to work as soon as it's procedure is moved to a C# class file
<p>I'm using C# ASP.NET VS2010.</p>

<p>I have a procedure on an .aspx.cs that reads a XML file and works just fine.</p>

<p>It goes like this:</p>

<pre><code>string fileName = "~/App_Data/" + filename + ".xml";
DataSet ds = new DataSet();
ds.ReadXml(MapPath(fileName));
</code></pre>

<p>I use this procedure alot to read various files with minimal changes (the file name), therefore, I tried to put the procedure in a Class1.cs file (in the App_Code folder), but I get this error message:</p>

<pre><code>The type or namespace name 'MapPath' does not exist in the namespace 'Microsoft.SqlServer.Server' (are you missing an assembly reference?)
</code></pre>

<p>I use this MapPath to read an XML file into a dataset this way:</p>

<pre><code>ds.ReadXml(Server.MapPath(fileName));
</code></pre>

<p>The filename is a string variable declared a few lines earlier:</p>

<pre><code>string fileName = "~/App_Data/" + inputString + ".xml";
</code></pre>

<p>After putting this line in the class.cs file, the VS2010 asked to resolve the missing <code>Server</code> by replacing it into <code>Microsoft.SqlServer.Server</code> locally (at the same line and not by adding a namespace) , so the line in it's new form looks like this:</p>

<pre><code>ds.ReadXml(Microsoft.SqlServer.Server.MapPath(fileName));
</code></pre>

<p>For the record, I made sure that all namespaces on the source .aspx.cs file are at the class file.</p>

<p>Why the difference between the Class1.cs and the .aspx.cs?</p>

<p>How do I workaround this?</p>

<p>What should I change in order to read the XML file from this new class file?</p>

<p>Is there a replacement for my line to read the XML file into the dataset?</p>
