Beispiel #1
0
 static void Main(string[] args)
 {
     try
     {
         var fileSender = new FileSender(args[0], int.Parse(args[1]), args[2]);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
Beispiel #2
0
 public void sendFile(FileSender data)
 {
     try
     {
         serialization.writeToStream(networkStream, data);
     }catch (SocketException ex)
     {
         Console.Error.WriteLine("Error writing to server scoket", ex);
         Console.ReadKey();
     }
 }
        static void Main(string[] args)
        {
            Client     client;
            FileSender fileSender;

            client = new Client();

            client.connect();

            String path = "../../test.txt";

            using (FileStream fileStream = File.OpenRead(path))
            {
                String filename = Path.GetFileName(path);
                byte[] data     = File.ReadAllBytes(path);
                fileSender = new FileSender(filename, data);
            }

            client.sendFile(fileSender);
            Console.WriteLine("File has been sent");
            Console.ReadKey();
        }