Hi,
Add the file to the project, select it in the project explorer, click
properties, select "embedded resource"
then use this code to extract it:
static string ExtractResource( string resourceName)
{
//look for the resource name
foreach( string currentResource in
System.Reflection.Assembly.GetExecutingAssembly(). GetManifestResourceNames()
)
if ( currentResource.LastIndexOf( resourceName) != -1 )
{
string fqnTempFile = System.IO.Path.GetTempFileName();
string path = System.IO.Path.GetDirectoryName( fqnTempFile);
string rootName= System.IO.Path.GetFileNameWithoutExtension(
fqnTempFile);
string destFile = path + @"\" + rootName + "." +
System.IO.Path.GetExtension( currentResource);
System.IO.Stream fs =
System.Reflection.Assembly.GetExecutingAssembly(). GetManifestResourceStream(
currentResource);
byte[] buff = new byte[ fs.Length ];
fs.Read( buff, 0, (int)fs.Length);
fs.Close();
System.IO.FileStream destStream = new System.IO.FileStream ( destFile,
FileMode.Create);
destStream.Write( buff, 0, buff.Length);
destStream.Close();
return destFile;
}
throw new Exception("Resource not found : " + resourceName);
}
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Jan" <Ja*@discussions.microsoft.com> wrote in message
news:33**********************************@microsof t.com...
Hi,
What I want is to add a text file to my project which will be
included/embedded in my exe file.
So not a link to a text file in a folder but a text file physical in the
exe.
Is this possible..? How can I access the content of the file..?
Jan