TelegramBots / Telegram.Bot

.NET Client for Telegram Bot API
https://telegrambots.github.io/book
MIT License
3.22k stars 690 forks source link

c# send a file image #899

Closed ahron33 closed 4 years ago

ahron33 commented 4 years ago

i am trying to get this working but i got an error on this filetosend thing

what is this?

`WebRequest req = WebRequest.Create("http://google.com"); req.Method = "GET";

        using (var response = await req.GetResponseAsync())
        using (var stream = response.GetResponseStream())
        {
            await bot.SendDocumentAsync(e.Message.Chat.Id, new FileToSend("file.html", stream));
        }`
tuscen commented 4 years ago

Please, follow issue template. As I can see you're using pretty old version of the library. I couldn't replicate the problem with the latest version.

ahron33 commented 4 years ago

Please, follow issue template. As I can see you're using pretty old version of the library. I couldn't replicate the problem with the latest version.

so what could i do to fix it update to what version?

tuscen commented 4 years ago

The latest one: 15.5.1

ahron33 commented 4 years ago

The latest one: 15.5.1

its on this version..

tuscen commented 4 years ago

FileToSend type has long been removed. You can read migration guide about breaking changes here https://telegrambots.github.io/book/Migration-Guide-to-Version-14.x.html.

ahron33 commented 4 years ago

FileToSend type has long been removed. You can read migration guide about breaking changes here https://telegrambots.github.io/book/Migration-Guide-to-Version-14.x.html.

thanks! i did it with this code

Stream stream = System.IO.File.OpenRead("Screenshot_8.png"); await bot.SendPhotoAsync(e.Message.Chat.Id, stream);