I'm trying to write text to file on server from winform desktop application
string path = "http://www.site.info/doc.txt";
To use path:
System.Web.HttpContext.Current.Server.MapPath(path);
also I tried this way:
System.Web.Hosting.HostingEnvironment.MapPath(path);
to write text into the text document:
using (StreamWriter _testData = new StreamWriter(Server.MapPath("~/doc.txt"), true))
{
_testData.WriteLine("TEXT");
}
Seems like I'm doing something wrong,
name
Server
"does not exists in current context".
Not sure how to use Server.MapPath
.
it is in References as System.Web
not System.Web.dll
, not sure, but it must be same, and in using as System.Web;
Also I am using System.Net;
so maybe I can do it with WebClient
.