【问题标题】:Why i get URI formats are not supported in c#?为什么我在 c# 中不支持 URI 格式?
【发布时间】:2017-02-04 23:23:40
【问题描述】:

我是 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");
                                        }


但在这一行:

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


收到此错误:

URI formats are not supported


我该如何解决这个问题?谢谢。

【问题讨论】:

标签: c#


【解决方案1】:

我建议您为此使用 WebClient 而不是 FileStream。这是一个可能对您有所帮助的链接:URL Formats are not supported

希望对你有帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-12
    • 1970-01-01
    • 1970-01-01
    • 2017-11-23
    • 2012-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多