I have an desktop application running on my desktop. I need to send the file path to the CGI script running at server. CGI script taks the file path and upload the contents from my machine.
I tried to send the file path through httppost method; it is not working - can any one suggest me how to do.. methods I have tried are:
WebClient upload = new WebClient();
NetworkCredential nc = new NetworkCredential("test", "admin");
Uri URL = new Uri("http:\\10.10.21.55\\cgi-bin\\file_upload.cgi");
upload.Credentials = nc;
byte [] data = upload.UploadFile(filepath, "c:/Data.txt");
Console.WriteLine(data.ToString());
and the other way I tried is:
byte[] buf = new byte[8192];
// prepare the web page we will be asking for
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create("http://10.10.21.55/cgi-bin/file_upload.cgi");
WebResponse rsp = null;
request.Method = "POST";
request.ContentType = "text/xml";
StreamWriter writer = new StreamWriter(request.GetRequestStream());
writer.WriteLine("hi hiw are you");
writer.Close();
both ways are not working.
but the below answered code works in desktop in winmo its telling WebClient not implimented... please tell how to send data to script present in server in windows mobile