Copying .exe file from Project

bunze

Well-known member
Joined
Aug 4, 2005
Messages
52
Location
Adirolf
Programming Experience
1-3
I went to add existing item and selected my .exe. Now, I want to copy it to "C:\Program1" when I run it. I tried:

file.copy(projectname.name.exe, "C:\Program1")

But it can't find the file.

also should this be an embedded resource or content or something? (in the properties)
 
Not working. the other .exe isn't in a folder, I went to "add existing item" and now its in the project. When I run that it says file not found and leads a path to my docs\prjects\project1\bin and so on
 
I hope I understand you correctly... If you want to embed a file inside your application during design time, and then extract it to a folder at run-time.

Just ignore my previous post, this is my first experience too :)

Just be careful of the resource name, it is case sensitive and you have to write them in full and not merely the filename. Hope this helps...
 

Attachments

  • Extract Embedded File.zip
    70.5 KB · Views: 50
Sorry but it didn't work for me that way. There must be a shorter easier way.

To copy a file its so simple...

file.copy("orginal path", "new path")

But I need for an embedded file. Well, Im not sure if its embedded. Add Existing Item and I can change its properties to stuff like "content" and "embedded resource" and others..
 
To copy a file its so simple...

file.copy("orginal path", "new path")

I don't understand this part... if you want to use the file.copy way then why must you embed? Because if you embed, you cannot make it that way. Embedded file is contained in the EXE or DLL file and therefore has no 'original path'. You have to extract the file from the application itself...
 
First thing u have to check is do u have a folder called C:\Program1 or is this the file name u want to copied as... Do u want to keep ur exe (running as embedded resource and then extract it and copy)
 
I have my original program. You go in it and click "Extract" and all I want it to do is: extract the other .exe file and place it in a folder.
 
Try this,

Once u add the exe to ur solution change the property 'Build Action' to 'Embedded Resource'

And in the code u can extract the resource as follows
Dim resourceStream As System.IO.Stream
resourceStream = System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream(assemblyNameWithoutExtension & "." & resourceFileName)

Dim file as New FileStream(savePath,FileMode.Create,FileAccess.Write)

Dim bufferSize as Integer = 256
Dim buffer(bufferSize) as Byte
Dim bytesRead as Integer

bytesRead = resourceStream.Read(buffer,0,bufferSize)
While (bytesRead >0)



 
missed it
rest is

While (bytesRead >0)
fileStream.Write(buffer,0,bytesRead)
bytesRead = resourceStream.Read(buffer,0,bufferSize)
End While
resourceStream.Close()
fileStream.Close()
 
Back
Top