【发布时间】:2013-07-01 20:46:36
【问题描述】:
如何使用相对路径从 XAML 应用程序中的文件夹中获取所有文件?
我正在使用 WPF 中构建的 Kinect 应用程序。应用程序中使用的所有图像都在
[project dir]\Images\ 和所有背景都在
[project dir]\Images\Backgrounds\。
我想使用相对路径从背景目录中获取所有图像的列表。我试过了
DirectoryInfo(@"\Images\Backgrounds\").GetFiles();
但它说背景目录必须存在于[full path+project dir]\debug\bin\
手动选择每个图像效果很好
Uri uri = new Uri(@"Images\Backgrounds\Background1.png", UriKind.Relative);
ImageSource imgsource = new BitmapImage(uri);
this.Backdrop.Source = imgsource;
【问题讨论】:
标签: c# wpf xaml directory relative-path