2017-02-04 88 views
1

我在C#中新,寫這樣的代碼:
爲什麼我的URI格式在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 


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

+0

請參閱此問題的答案:http://stackoverflow.com/questions/3460503/how-to-read-a-file-from-a-uri-using-streamreader – Sparrow

+0

爲什麼在「/」時分裂沒有在你的源字符串中? – pinkfloydx33

回答