2016-11-10 94 views
0

我使用以下代碼:編輯路徑XAML

String filepath = e.fullpath; 
Image.source = new BitmapImage(new uri(filepath)); 

文件路徑的輸出是:

file:///c://Folder//Location//Name.jpg 

其投擲誤差Image.Source

圖片所需的路徑格式:

c:/Folder/Location/name.jpg 

請幫幫忙,

預先感謝您

+0

@MongZhu我使用filewatcher被檢索的路徑。 – user5928466

+0

'filepath = filepath.Replace(「file:///」,「」);'? – Pikoh

+0

@Pikoh沒有改變。我想將「//」更改爲「/」。 – user5928466

回答

0

試試這個:

String filepath = e.fullpath; 
Image.source = new BitmapImage(new Uri(filepath).LocalPath);