我在 c# System.URI.FormatExption
中遇到问题
为了清楚起见,我使用的是 Segseuil
的 Matlab 方法,并且它返回一个图片路径 kết quả
。我想为其他用户保存此图像,但出现异常。
private void segmenter(object sender, RoutedEventArgs e) {
s.SegSeuil(0, (MWCharArray)name, (MWCharArray)result);
BitmapImage tmp = new BitmapImage(new Uri(result)); // exception here
image.Source = tmp;
}
nếu nhưkết quả
是相对路径,例如image.jpg你必须使用UriKind.Relative
:
BitmapImage tmp = new BitmapImage(new Uri(result, UriKind.Relative));
hoặcRelativeOrAbsolute
:
BitmapImage tmp = new BitmapImage(new Uri(result, UriKind.RelativeOrAbsolute));
确保结果文件存在于您的 .exe
文件中或包含您的 exe 文件的文件夹中。
nếu nhưkết quả
是绝对路径,例如:
D:\image.jpg可以使用:
BitmapImage tmp = new BitmapImage(new Uri(result));
或:
BitmapImage tmp = new BitmapImage(new Uri(result, UriKind.Absolute));
或:
BitmapImage tmp = new BitmapImage(new Uri(result, UriKind.RelativeOrAbsolute));
Tôi là một lập trình viên xuất sắc, rất giỏi!