簡體   English   中英

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

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

我是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


我該如何解決這個問題?謝謝。

我建議您使用WebClient而不是FileStream 這是一個可能對您有所幫助的鏈接: 不支持URL格式

希望能幫助到你!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM