Results 1 to 4 of 4

Thread: Copy resource to file system?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2010
    Posts
    17

    Copy resource to file system?

    I'm writing a program that I want to attach another program (.exe) to. I tried adding it as a resource, but I can't seem to get the resource to export out to wherever the program is running.

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Copy resource to file system?

    Why would you want to include an exe in your application like that? I'm not 100% on this but if your application extracts an .exe file "on the fly" like that, certain Antivirus software might flag it as a possible malicious action.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2010
    Posts
    17

    Re: Copy resource to file system?

    I hadn't thought of that.

    Basically, I'm trying to deploy my application with another application I've previously written.

  4. #4
    Lively Member
    Join Date
    Jan 2010
    Location
    United Kingdom
    Posts
    115

    Re: Copy resource to file system?

    Hi there

    The code example below shows how I did what you're asking.

    For this to work you need to add the following at the very top of your forms code, before the Public Class Form statement.

    Code:
    Imports System.IO
    First, I check to see if the directory containing the exe exists. If not I create it.
    Code:
    If Not Directory.Exists(full folder path here) Then
                Directory.CreateDirectory(full folder path here)
            End If
    Next, I copy the exe from my.resources to the created directory.
    Code:
    If Not File.Exists(full path to file including filename and extension) Then
                File.WriteAllBytes(full path to file including filename and extension, My.Resources.yourprogram)
            End If
    Hope this helps.
    Regards
    Colin

    If my comments helped please remember to add to my reputation using Rate This Post.

    If your problem has been resolved please mark the thread resolved using the "Mark Thread Resolved" link in thread tools.

    CodeBank Submissions: 1) WebBrowser - Delete cookies etc 2) Import My.Settings from previous build version

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width