How To Copy File From Resources

matto

New member
Joined
Apr 18, 2009
Messages
3
Hi,

I have some code which copies 2 files to a folder. These 2 files are included in the current application folder. Is it possible to embed these 2 files into the .exe and copy them to a destination folder? Heres my code so far:

[VB]Dim CurrentLocationDll As String = Application.StartupPath & "\FILE.dll"
Dim DestinationFolder As String = System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\FOLDER"
If (FileIO.FileSystem.FileExists(CurrentLocationDll)) Then

ProgressBar1.PerformStep()
If (FileIO.FileSystem.FileExists(DestinationFolder & "\FILE.dll")) Then
FileIO.FileSystem.MoveFile(DestinationFolder & "\FILE.dll", DestinationFolder & "\FILE.dll.bak")
ProgressBar1.PerformStep()
End If

FileIO.FileSystem.CopyFile(CurrentLocationDll, DestinationFolder & "\FILE.dll")
ProgressBar1.PerformStep()
End If[/VB]
 
I looked through the guides, didnt need it in the end xD

Managed to find an example with a .dll and it worked for me. Thanks for helping
 
One thing to be careful with though is the fact than on XP or later only administrators will have permissions to write to the Program Files folder (Im assuming that is where your application is being installed) so for non-admins this technique might not work. On Vista or later there is a good chance the end user will be annoyed by UAC prompts even if they are admins every time they run this app.
 
Back
Top