mercredi 31 décembre 2014

The namespace 'MapPath' does not exist in the namespace

I am trying to use the code below to gather information from website and give the detail in HTML file. will I am trying to run the code I get error that



Error 41 The type or namespace name 'MapPath' does not exist in the namespace 'Microsoft.SqlServer.Server' (are you missing an assembly reference?)



the code is



WebRequest request = WebRequest.Create("http://www.google.com/");// url here
using (WebResponse response = request.GetResponse())
{
using (StreamReader responseReader = new StreamReader(response.GetResponseStream()))
{
string responseData = responseReader.ReadToEnd();
string path = Microsoft.SqlServer.Server.MapPath(".");
if (!File.Exists(path + "//Asptrick.html"))
File.Create(path + "//Asptrick.html");
using (StreamWriter writer = new StreamWriter(path + "//Asptrick.html")) //Where You Want to save Content
{
writer.Write(responseData);
}
}
}


i have tried with



Server.MapPath("~")
Server.MapPath(@"\")
Server.MapPath("/")


but can not get it to work


the following are in used as well



using System.Net;
using System.IO;




Aucun commentaire:

Enregistrer un commentaire