06 September 2005

Putting binary object into .net resource file


Before I delete (and forget) how to import binary object such like image into .Net resouce file here is the script to do it with Nunit.


[Test]
[Ignore("Use this test to create resource file only")]
public void WriteResouceFile()
{
ResXResourceWriter rsxw = new ResXResourceWriter("TestData.resx");
rsxw.AddResource("BirdsBritannica_JacketImage",Image.FromFile("BirdsBritannica.jpg"));
rsxw.AddResource("BirdsBritannica_Title","Birds Britannica");
rsxw.AddResource("BirdsBritannica_Review","Another magnificent achievement and a unique work ... ");
rsxw.AddResource("BirdsBritannica_ISBN","0701169079");

rsxw.AddResource("Coast_JacketImage",Image.FromFile("Coast.jpg"));
rsxw.AddResource("Coast_Title","Coast");
rsxw.AddResource("Coast_Review","Accompanying the BBC series, Coast is not only a superbly illustrated ...");
rsxw.AddResource("Coast_ISBN","0563522798");

rsxw.AddResource("TheDaVinciCode_JacketImage",Image.FromFile("TheDaVinciCode.jpg"));
rsxw.AddResource("TheDaVinciCode_Title","The Da Vinci Code");
rsxw.AddResource("TheDaVinciCode_Review",@"With The Da Vinci Code, Dan Brown masterfully concocts an intelligent...");
rsxw.AddResource("TheDaVinciCode_ISBN","0552149519");
rsxw.Close();
}

No comments: