Пример #1
0
 private void OnServerFileNotFound(object sender, FileRequestEventArgs e)
 {
     e.Connection.SendMessageCarrier(new MessageCarrier(MessageType.FileNotFound)
     {
         Payload = e.FilePathAndName
     });
 }
Пример #2
0
        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);
            }
        }