简体   繁体   English

为什么我在c#中不支持URI格式?

[英]Why i get URI formats are not supported in c#?

I'm new in c#,and write this code: 我是c#的新手,写下这段代码:

const string file ="http://ipaddress/"+"1.jpg";
                                        var fileName = file.Split('\\').Last();
                                        using (var fileStream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read))
                                        {
                                            var fts = new FileToSend(fileName, fileStream);
                                            await Bot.SendPhotoAsync(update.Message.Chat.Id, fts, "Nice Picture");
                                        }


but in this line: 但在这一行:

using (var fileStream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read))


get this error: 得到这个错误:

URI formats are not supported


How can i solve that problem ?thanks. 我该如何解决这个问题?谢谢。

I'd suggest you use WebClient instead of FileStream for this. 我建议您使用WebClient而不是FileStream Here's a link that might help you: URL Formats are not supported 这是一个可能对您有所帮助的链接: 不支持URL格式

Hope it helps! 希望能帮助到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM