Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
c#如何获取资源文件夹中所有项目的文件路径_C#_Wpf_List_File_Resources - Fatal编程技术网

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
}