private void OnServerFileNotFound(object sender, FileRequestEventArgs e)
 {
     e.Connection.SendMessageCarrier(new MessageCarrier(MessageType.FileNotFound)
     {
         Payload = e.FilePathAndName
     });
 }
        private void OnServerSendFile(object sender, FileRequestEventArgs e)
        {
            FileStream fs = new FileStream(e.FilePathAndName, FileMode.Open, FileAccess.Read);

            byte[] bytes = File.ReadAllBytes(e.FilePathAndName);
            fs.Read(bytes, 0, Convert.ToInt32(fs.Length));
            fs.Close();

            e.Connection.SendMessageCarrier(new MessageCarrier(MessageType.FileContents)
            {
                Payload = bytes
            });
        }
示例#3
0
        public void Push(FileTunnelServerConnection connection, string filePathAndName)
        {
            var request = new FileRequestEventArgs(connection, filePathAndName);

            if (File.Exists(filePathAndName))
            {
                requestStack.Push(request);
            }

            else
            {
                FileNotFound?.Invoke(this, request);
            }
        }