private void upload1_Click(object sender, RoutedEventArgs e) { // Make sure we can perform this action with valid data if (ValidateRemoteHost()) //SET THIS TO TRUE IF YOU WANT TO BYPASS BLANK INPUT { /* // Socket sListen = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPAddress IP = IPAddress.Parse(txtRemoteHost.Text); IPEndPoint IPE = new IPEndPoint(IP, 7070); // sListen.Bind(IPE); //WP 7.1 does not support this! Console.WriteLine("Service is listening ..."); // sListen.Listen(2); //WP 7.1 does not supprot this! while (true) { Socket clientSocket; try { clientSocket = sListen.Accept(); } catch { throw; } // send data to the client //clientSocket.Send (Encoding.Unicode.GetBytes ("I am a server, you there?? !!!!")); // send the file byte[] buffer = ReadImageFile("1.jpg"); clientSocket.Send(buffer, buffer.Length, SocketFlags.None); Console.WriteLine("Send success!"); } */ // Instantiate the TCPSocket SocketClient client = new SocketClient(); // Attempt to send our message to the server string result = client.Connect(txtRemoteHost.Text, IMAGE_PORT); // Receive a response from the server // result = client.Send(); //string imageinstringformat = image2.Source; //string location = @"\" + image2; //Debug.WriteLine("Where is it? " + location); //Debug.WriteLine(image2.ToString()); //byte[] buffer = ReadImageFile(image2); //string message = "hello"; //ReadImageFile(image2); // result = client.Send(Encoding.UTF8.GetBytes(message)); string base64String = Convert.ToBase64String(ReadImageFile(image2)); //Debug.WriteLine("I'm sending this: " + base64String); Debug.WriteLine("First part of the buffer: " + Encoding.UTF8.GetBytes(base64String + "<EOF>").Length); result = client.Send(Encoding.UTF8.GetBytes(base64String)); Console.WriteLine("Send success!"); // Close the socket connection explicitly // client.Close(); } }