[WinForm] How to get the file path of the Resources folder in the project

Here is a story, the problem encountered by Xiaobai in the story character may be the same as yours, find a solution from the boss, please continue to read, maybe it can help you

小白 大佬 大佬,您好! 有个问题,是这样的 我在WinForm项目中的资源属性添加了一些文件 您看 小白 大佬

As shown in the figure below, it is convenient to package and publish together
insert image description here

If you want to use it at that time, you only need to call the following resource Resources object

var file = Resources.adb;
var img = Resources.img1;
//...
小白 大佬 问题就在 我只想要获取资源文件夹Resources的文件路径 应该怎么做呢? 我看看 小白 大佬

Code to get file path

var p = new Process();
p.StartInfo.FileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "adb.exe");
//...
小白 大佬 代码没问题吧 有没有发现还差点什么 愿闻其详 这样做... 小白 大佬

Select the resource file, as shown in the figure below,
insert image description here
in the file attribute column, set all the required files to be copied to the output directory.
insert image description here

小白 大佬 学到了,多谢大佬! 先别跑!给我点个赞再走。 小白 大佬

Guess you like

Origin blog.csdn.net/zs1028/article/details/129872428