-1
所以我试图在C#中使用VB.NET 2012中的TweetSharp发布带图片的推文。如何将SendTweetWithMedia与TweetSharp一起使用?
我发现了如何做到这一点的代码示例:
service.SendTweetWithMedia(new SendTweetWithMediaOptions
{
Status = "message",
Images = dictionary
}
);
但是我不知道如何创建“字典”与画面流。
我尝试这样做:
Dictionary<string, Stream> imageDict = new Dictionary<string, Stream>();
那么以后引用:
Images = imageDict
但它给人的错误:
人有怎样,这是任何想法应该工作?
另一个代码块,我发现并试图为:
using (var stream = new FileStream("Image.jpg", FileMode.Open))
{
var result = tservice.SendTweetWithMedia(new SendTweetWithMediaOptions
{
Status = "Message",
Images = new Dictionary<string, Stream> { { "john", stream } }
});
lblResult.Text = result.Text.ToString();
}
但它提供了有关“的FileStream”同样的错误。
我完全错过了!非常感谢。现在我得到另一个错误。它现在完美发布图像,但如果图像很大,“结果”会以Null(发生错误)的形式出现,则会引发NullRefrenceException。我怎么能错误检查这个?我尝试了一个Try/Catch块,但它没有奏效。 –