Run command in C# 
System.Diagnostics.Process process1;
process1= new System.Diagnostics.Process();

//Do not receive an event when the process exits.
process1.EnableRaisingEvents = false;


string strCmdLine="/C curl -E \""+CertFile+"\":\""+CertPass+"\" -F orgid="+OrgID+" -F batchid="+this.BatchID+" -F userid="+PDSOID+" -F xml=@\""+this.XMLFilePath+this.XMLFileName+"\" "+UploadURL+" -o \""+this.XMLFilePath+"\\ServerResponse.xml\"";
try
{
System.Diagnostics.ProcessStartInfo sinf = new System.Diagnostics.ProcessStartInfo ("cmd.exe", @strCmdLine);
sinf.UseShellExecute = false;
sinf.CreateNoWindow = true;

process1.StartInfo=sinf;

process1.Start();
process1.WaitForExit();
process1.Close();

// or System.Diagnostics.Process.Start("cmd.exe",@strCmdLine);

this.ReadTransferLog("ServerResponse.xml");

return this.TranStatus;
}
catch (Exception ex)
{
process1.Kill();
npuInfoDB.DBConnection.LogErrorMessage(strCmdLine+"\n"+ex.Message);
return false;
}

[ add comment ]   |  permalink  |  related link  |   ( 3 / 9065 )
Read online file in C# 
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.theserverside.net");
System.Net.WebProxy myProxy = new System.Net.WebProxy("Your proxy goes here", 8081);
myProxy.BypassProxyOnLocal = true;
request.Proxy = myProxy;request.MaximumAutomaticRedirections = 4;
request.MaximumResponseHeadersLength = 4;
request.Timeout=20000;
request.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse response = (HttpWebResponse)request.GetResponse ();
Stream receiveStream = response.GetResponseStream ();
StreamReader readStream = new StreamReader (receiveStream, Encoding.UTF8);
string result=readStream.ReadToEnd ();
response.Close ();


[ add comment ]   |  permalink  |  related link  |   ( 3 / 2515 )

BackBack