Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Enter IP remote host");
                remoteIpAddress = IPAddress.Parse(Console.ReadLine().ToString());
                endPoint        = new IPEndPoint(remoteIpAddress, PORT);

                ConsoleKeyInfo keyInfo = new ConsoleKeyInfo();
                PersonInfo     personInfo;
                do
                {
                    Console.WriteLine("Enter the path and name file with extention");
                    personInfo = new PersonInfo();
                    fileStream = new FileStream(Console.ReadLine().ToString(), FileMode.Open, FileAccess.Read);

                    if (fileStream.Length > 8192)
                    {
                        Console.WriteLine("Google is a deceiver!");
                        Disconnect();
                        return;
                    }

                    SendFileInfo();
                    Thread.Sleep(1000);
                    SendFileData();

                    personInfo.AddInfoPerson(fileStream, remoteIpAddress, DateTime.Now);

                    personInfo.AddPerson(personInfo);
                    Console.WriteLine("Press Esc to exit or another key for enter the path:");
                    keyInfo = Console.ReadKey(true);
                    //fileStream.Close();  ??
                } while (keyInfo.Key != ConsoleKey.Escape);
                personInfo.ShowList();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Disconnect();
            }
        }