Extracting files from an EXE

Z

Zagor

Hi All,
I have a small exe app ( basic a dialog box) that when lauched needs to
"copy" some files in a directory chosen by the user (within the dialog). I
cannot use an installation package because there are some particular tasks
to be done from the exe.
Anyhow I was wondering if it possibile to include files within the (C#)exe
and then extract them from the exe when launched...sort of an installation.
I was thinking to add them as resources but I do not know how to extract
them.

Please any hint will be appreciated

Thank you
Zagor
 
S

SStory

There is Zip genius software.

You can zip a file and then direct it unzip all files to a directory and
then run an exe if it is named Setup.exe.

That would get the files in a directory and then run your exe.

Otherwise, this sounds a lot like a virus.
 
V

VJ

Are you looking to extract the embbedded files from the exe to extract when
your exe launches?.. If the answer is yes... then here is what you do... in
your code at you can do this..

string includeFileName = "MyApplication.MySapce.Trial.jpg";
string strNewPathToSave = @"C:\MyNewPath\Trial.jpg";

System.IO.Stream myFile
= System.Reflection.Assembly.GetManifestResourceStream(includeFileName);

if ( myFile== null )
return "Unable to read the License file."; //"Inspherion License file is
not valid. Please contact Inspherion Support";

System.IO.FileStream fs = System.IO.File.OpenWrite(strNewPathToSave);
try
{
// Save the File...
byte[] buffer = new byte[myFile.Length];
myFile.Read(buffer,0,(int)myFile.Length);
fs.Write(buffer,0,buffer.Length);
}
finally
{
fs.Close();
}

Remeber that.. the includeFileName has to be fully qualified with Namespace
used by the executable or assembly where the file is embbeded.

HTH
VJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top