|
-
Jun 5th, 2010, 08:48 PM
#1
Thread Starter
Junior Member
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.
-
Jun 5th, 2010, 08:52 PM
#2
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.
-
Jun 5th, 2010, 08:54 PM
#3
Thread Starter
Junior Member
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.
-
Jun 6th, 2010, 03:15 AM
#4
Lively Member
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.
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|