嵌入式资源文件的路径 [英] Path to an embedded resource file

查看:83
本文介绍了嵌入式资源文件的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的资源文件中有一个要引用的图标.

I have an icon in my resource file , which I want to reference.

这是需要图标文件路径的代码:

This is the code that needs that path to an icon file:

IWshRuntimeLibrary.IWshShortcut MyShortcut  ;
MyShortcut =   (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\PerfectUpload.lnk");
MyShortcut.IconLocation = //path to icons path . Works if set to @"c:/icon.ico" 

我希望它没有找到外部图标文件,而是希望找到一个嵌入式图标文件.

Instead of having an external icon file I want it to find an embedded icon file. Something like

MyShortcut.IconLocation  = Path.GetFullPath(global::perfectupload.Properties.Resources.finish_perfect1.ToString()) ;

这可能吗?如果可以,怎么办?

is this possible ? if so how ?

谢谢

推荐答案

我认为它将在某些方面为您提供帮助...

I think it will help you in some what...

//Get the assembly.
System.Reflection.Assembly CurrAssembly = System.Reflection.Assembly.LoadFrom(System.Windows.Forms.Application.ExecutablePath);

//Gets the image from Images Folder.
System.IO.Stream stream = CurrAssembly.GetManifestResourceStream("ImageURL");

if (null != stream)
{
    //Fetch image from stream.
    MyShortcut.IconLocation = System.Drawing.Image.FromStream(stream);
}

这篇关于嵌入式资源文件的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆