如何在没有 Visual Studio 的情况下使用嵌入到应用程序中的资源

发布于 2025-01-12 20:24:53 字数 302 浏览 3 评论 0原文

我有一个使用 winforms 的 GUI 项目,并且想在其中使用一些图标。 我不使用 Visual Studio 来实现此目的,而是使用 dotnet cli 构建它。 虽然从单独的文件加载它们时它可以工作,但我希望它们作为资源放在可执行文件中。我通过 csproj 中的此条目添加了整个文件夹:

<EmbeddedResource Include="Resources\*.png" />

但是我如何引用它们并将它们加载到 Image 对象中? 我发现的所有示例都使用 Visual Studio 的 GUI。

I have a GUI project using winforms, and want to use some icons inside it.
I don't use Visual Studio for this, but build it with dotnet cli.
While it is working when they are loaded from seperate files, i want them inside the executable as a resource. I added the whole folder via this entry in the csproj:

<EmbeddedResource Include="Resources\*.png" />

But how would i reference them and e.g. load them into an Image object?
All examples i have found are using the GUI of Visual studio for it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文