extracting an exe file from resource

Posted on 2009-12-25
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

    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

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Suggested Solutions

    How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from ( Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    730 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now