using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Threading;
using System.Security.Principal; //get a user id
namespace passdata1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("enter number 1 ");
string number1 = Console.ReadLine();
Console.WriteLine("enter number 2 ");
string number2 = Console.ReadLine();
/*StreamWriter w = new StreamWriter(@"c:input.txt");
w.WriteLine(number1);
w.WriteLine(number2);
w.Close();*/
File.Delete(@"c:\output.txt");
//start another program as a thread
System.Diagnostics.Process.Start(@"H:\class 28\passdata2\passdata2\bin\Debug\passdata2.exe", number1+" "+number2);
//third parameter pass name to other program
string ip = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList[0].ToString();
Console.WriteLine(ip);
string user = WindowsIdentity.GetCurrent().Name.ToString();
Console.WriteLine(user);
while (true)
{
if (File.Exists(@"c:\output.txt"))
{
break;
}
else
{
Thread.Sleep(100);
}
}
StreamReader r = new StreamReader(@"c:\output.txt");
string s = r.ReadLine();
r.Close();
Console.WriteLine(s);
Console.ReadLine();
}
}
}
----------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading.Tasks;
using System.IO;
namespace passdata2
{
class Program
{
static void Main(string[] args)
{
/*StreamReader r = new StreamReader(@"c:\input.txt");
double x = Convert.ToDouble(r.ReadLine());
double y = Convert.ToDouble(r.ReadLine());*/
double x = Convert.ToDouble(args[0]);
double y = Convert.ToDouble(args[1]);
double z = x + y;
//r.Close();
StreamWriter w = new StreamWriter(@"c:\output.txt");
w.WriteLine(z);
w.Close();
}
}
}
No comments:
Post a Comment