Learn how to a build a cloud-first strategyRegister Now


extracting an exe file from resource

Posted on 2009-12-25
Medium Priority
Last Modified: 2013-12-17
i have an exe file in my resource application that i want to extract and run it using process.start() method in c#, any one can help me how to extract it ?
Question by:shabrandi
1 Comment
LVL 10

Accepted Solution

RameshS earned 2000 total points
ID: 26123398
Try this code.
The following code can be used to extract the embbedded files. Here the includeFileName has to be fully qualified with Namespace used by the executable or assembly where the file is embbeded.

string includeFileName = "MyApplication.MySapce.Sample.exe";
string strNewPathToSave = @"C:\MyNewPath\Sample.exe";

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

if ( myFile== null )
   return "Unable to read the file."; 

System.IO.FileStream fs = System.IO.File.OpenWrite(strNewPathToSave);
    // Save the File...
    byte[] buffer = new byte[myFile.Length];

Open in new window


Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question