我的问题是这样的:有如下代码:有一句是复制一个.ico文件到C:\windows目录下边。这个.ico文件在我编译程序时在我的程序Debug目录下边,编译好的程序可以正常运行。但是当我把程序移植到别的电脑上就提示无法找到图片路径。我现在想知道如何将这个.ico文件加到程序里面一遍在别的电脑上也可以正常运行。
private void btnSetSmallArrow_Click(object sender, EventArgs e)
{
RegistryKey rKey = Registry.LocalMachine;
RegistryKey rSetSmallArrow = rKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer", true);
rSetSmallArrow.CreateSubKey("Shell Icons");
rSetSmallArrow = rKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons", true);
File.Copy("Arrow.ico", "C:\\Windows\\Arrow.ico",true);//在移植到别的电脑上报错,如何将图片嵌入程序中呢?
rSetSmallArrow.SetValue("29", "C:\\Windows\\Arrow.ico,0", RegistryValueKind.String);
rSetSmallArrow.Close();
rKey.Close();
Process[] myPr;
myPr = Process.GetProcessesByName("explorer");
foreach (Process mypr in myPr)
{
mypr.Kill();
}
MessageBox.Show("修改成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void btnSetSmallArrow_Click(object sender, EventArgs e)
{
RegistryKey rKey = Registry.LocalMachine;
RegistryKey rSetSmallArrow = rKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer", true);
rSetSmallArrow.CreateSubKey("Shell Icons");
rSetSmallArrow = rKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons", true);
File.Copy("Arrow.ico", "C:\\Windows\\Arrow.ico",true);//在移植到别的电脑上报错,如何将图片嵌入程序中呢?
rSetSmallArrow.SetValue("29", "C:\\Windows\\Arrow.ico,0", RegistryValueKind.String);
rSetSmallArrow.Close();
rKey.Close();
Process[] myPr;
myPr = Process.GetProcessesByName("explorer");
foreach (Process mypr in myPr)
{
mypr.Kill();
}
MessageBox.Show("修改成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
解决方案 »
- 请问每隔一分钟手动执行一次GC,合适吗??
- linq里面orderby是怎么排序的,稳定吗,效率是多少有没有人知道
- powerpoint可以再浏览中播放的原理是什么啊?
- C#中TreeView限制遍历深度问题
- 如何在.net中删除已经在窗体中引用并显示了的图像文件,为什么每次在删除的时候都提示说有别的进程占用
- .............C#用什么读中文xml?..................
- 为什么ADO.NET和XML结合的那么紧密?
- 求高数(工本)辅导人 (请版主勿删,我也很无奈)
- asp.net里面上传文件,不想用FILE FIELD,有好办法吗?
- 如何把一个文件保存在数据库的image字段中
- 求C#中system.IO包中的 file.copy这个方法传输的速度怎么获得
- 类中的一个事件如何在两个实例中调用
{
public class Class1
{
public void mydll()
{
this.GetType().Assembly.GetManifestResourceStream("Dll.image.test.jpg");
}
public System.IO.Stream ReturnStream()
{
return
this.GetType().Assembly.GetManifestResourceStream
("Dll.image.test.jpg");
}
}
}
这个不可以?或者加上 Application.StartupPath