Пример #1
0
        protected override void ProcessComplete(long chatId)
        {
            var path = Shell.GetPath(Path);

            if (File.Exists(path))
            {
                Task.Run(() =>
                {
                    try
                    {
                        using (var stream = File.OpenRead(path))
                        {
                            var filename   = System.IO.Path.GetFileName(path);
                            var fileToSend = new FileToSend(filename, stream);
                            TelegramApi.SendDocumentAsync(chatId, fileToSend).Wait();
                        }
                    }
                    catch (Exception ex)
                    {
                        TelegramApi.SendTextMessageAsync(chatId, "File sending error: " + ex.Message);
                    }
                    finally
                    {
                        Session.Exit(this);
                    }
                });
            }
            else
            {
                TelegramApi.SendTextMessageAsync(chatId, "File " + path + " not exists");
                Session.Exit(this);
            }
        }