tried to build a resource file with this code, // Create a resource file. This works. The file is
created and may be
added to the project
private void BuildResources()
{
IResourceWriter rw = new ResourceWriter
("XCursors.resources");
Cursor lc = new Cursor( "XLabelc.CUR");
rw.AddResource("CURLABEL", lc);
// add seven more cursors
rw.Close();
}
// code below fails with a long message telling
that "XCursors.resources" is not present
and have I made
// sure it's an embedded resource blah, blah
private void LoadCursors()
{
ResourceManager rm = new ResourceManager("XCursors",
this.GetType().Assembly);
Cursor testcursor = (Cursor)rm.GetObject
("CURLABEL");
}
// in the end I have to do this because the user hasn't
put the files in
his app directory.
private Cursor GetCursor( string filename)
{
try
{
return Cursor = new Cursor( filename);
}
catch
{
return Cursors.Cross;
}
}
For more information, please chech the following articles:319292.KB.EN-US HOW TO: Embed and Access Resources by Using Visual C# .NET
http://support.microsoft.com/default.aspx?scid=KB;EN-US;319292GetManifestResourceStream Method
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemReflectionAsse
mblyClassGetManifestResourceStreamTopic.asp
created and may be
added to the project
private void BuildResources()
{
IResourceWriter rw = new ResourceWriter
("XCursors.resources");
Cursor lc = new Cursor( "XLabelc.CUR");
rw.AddResource("CURLABEL", lc);
// add seven more cursors
rw.Close();
}
// code below fails with a long message telling
that "XCursors.resources" is not present
and have I made
// sure it's an embedded resource blah, blah
private void LoadCursors()
{
ResourceManager rm = new ResourceManager("XCursors",
this.GetType().Assembly);
Cursor testcursor = (Cursor)rm.GetObject
("CURLABEL");
}
// in the end I have to do this because the user hasn't
put the files in
his app directory.
private Cursor GetCursor( string filename)
{
try
{
return Cursor = new Cursor( filename);
}
catch
{
return Cursors.Cross;
}
}
For more information, please chech the following articles:319292.KB.EN-US HOW TO: Embed and Access Resources by Using Visual C# .NET
http://support.microsoft.com/default.aspx?scid=KB;EN-US;319292GetManifestResourceStream Method
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemReflectionAsse
mblyClassGetManifestResourceStreamTopic.asp
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货