c#如何获取资源文件夹中所有项目的文件路径
我正在尝试创建一个包含如下位图图像的列表c#如何获取资源文件夹中所有项目的文件路径,c#,wpf,list,file,resources,C#,Wpf,List,File,Resources,我正在尝试创建一个包含如下位图图像的列表 List<BitmapImage> Images = new List<BitmapImage> { new BitmapImage(new Uri(@"/Images/Car.bmp", UriKind.Relative)), }; 这是我正在谈论的文件夹的图片: 这里介绍如何按模式获取文件 string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExe
List<BitmapImage> Images = new List<BitmapImage>
{
new BitmapImage(new Uri(@"/Images/Car.bmp", UriKind.Relative)),
};
这是我正在谈论的文件夹的图片:
这里介绍如何按模式获取文件
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Images");
foreach (string file in Directory.GetFiles(path, "*.bmp"))
{
// there is file name
}
@MongZhu更新了答案,现在我在这里得到执行程序集的当前文件夹,并按扩展名得到所有文件
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Images");
foreach (string file in Directory.GetFiles(path, "*.bmp"))
{
// there is file name
}