okay so I have added a function to my c# script to fetch ip address and send the output as string in a variable heres my source
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using System.Net;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string URL = "http://localhost/test2.php";
WebClient webClient = new WebClient();
NameValueCollection formData = new NameValueCollection();
formData["var1"] = formData["var1"] = string.Format("MachineName: {0}", System.Environment.MachineName);
formData["var2"] = stringGetPublicIpAddress();
formData["var3"] = "DGPASS";
byte[] responseBytes = webClient.UploadValues(URL, "POST", formData);
string responsefromserver = Encoding.UTF8.GetString(responseBytes);
Console.WriteLine(responsefromserver);
webClient.Dispose();
System.Threading.Thread.Sleep(5000);
}
private static string stringGetPublicIpAddress()
{
throw new NotImplementedException();
}
private string GetPublicIpAddress()
{
var request = (HttpWebRequest)WebRequest.Create("http://ifconfig.me");
request.UserAgent = "curl"; // this simulate curl linux command
string publicIPAddress;
request.Method = "GET";
using (WebResponse response = request.GetResponse())
{
using (var reader = new StreamReader(response.GetResponseStream()))
{
publicIPAddress = reader.ReadToEnd();
}
}
return publicIPAddress.Replace("
", "");
}
}
}
basically I have created this function
private static string stringGetPublicIpAddress()
and I am sending it as a variable
formdata["var2"] = stringGetPublicIpAddress();
I am getting this error
throw new NotImplementedException(); === NotImplementedException was unhandled
See Question&Answers more detail:os