try
{
using (StreamReader reader = new StreamReader("Give file path" + "file name"))
{
filecontent = reader.ReadToEnd();
}
postData = @"file=" + HttpUtility.UrlEncode(filecontent) + "&submit=save";
byte[] data = Encoding.ASCII.GetBytes(postData);
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("Remote Server path");
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = data.Length;
Stream dataStream = webRequest.GetRequestStream();
dataStream.Write(data, 0, data.Length);
dataStream.Close();
HttpWebResponse webResponse;
webResponse = (HttpWebResponse)webRequest.GetResponse();
Stream answer = webResponse.GetResponseStream();
StreamReader _answer = null;
_answer = new StreamReader(answer);
string ResponseStatus = _answer.ReadToEnd();
}
catch (Exception ex)
{
}
{
using (StreamReader reader = new StreamReader("Give file path" + "file name"))
{
filecontent = reader.ReadToEnd();
}
postData = @"file=" + HttpUtility.UrlEncode(filecontent) + "&submit=save";
byte[] data = Encoding.ASCII.GetBytes(postData);
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("Remote Server path");
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = data.Length;
Stream dataStream = webRequest.GetRequestStream();
dataStream.Write(data, 0, data.Length);
dataStream.Close();
HttpWebResponse webResponse;
webResponse = (HttpWebResponse)webRequest.GetResponse();
Stream answer = webResponse.GetResponseStream();
StreamReader _answer = null;
_answer = new StreamReader(answer);
string ResponseStatus = _answer.ReadToEnd();
}
catch (Exception ex)
{
}
No comments:
Post a Comment