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)
 
Thanks but It's giving mr a problems with the "fileSteam" and this line of code:

resourceStream = System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream(assemblyNameWithoutExtension & "." & resourceFileName)

I changed the
assemblyNameWithoutExtension & "." & resourceFileName

to
Program2 & "." & proggy

but it didn't work. Do I need them in quotes? That gives me a problem too :(
 
well,, u have to give string arguments, for ex ur assembly name is Program2 and resource name is proggy
then
it should be like
GetManifestResourceStream("Program2.proggy")

Also there is another overloaded method of GetManifestResourceStream where u can just past only the resource name..
try it too
 
Dim resourceStream As System.IO.Stream
resourceStream = System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream("Program2.Proggy")

Dim files As New FileStream("C:\Documents and Settings\Owner\My Documents\Files", 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)
files.Write(buffer, 0, bytesRead)
bytesRead = resourceStream.Read(buffer, 0, bufferSize)
End While
resourceStream.Close()
files.Close()



And it says Access to "C:\Documents and Settings\Owner\My Documents\Files" is denied.
 
Didn't u try some other file path and you have to give the full path like
C:\Documents and Settings\Owner\My Documents\Files\Proggy.dat or C:\Documents and Settings\Owner\My Documents\Files\Proggy.exe or something.
 
just debug thro the code and check whether
bytesRead = resourceStream.Read(buffer, 0, bufferSize)
While (bytesRead > 0)
files.Write(buffer, 0, bytesRead)
is working, (mean reading bytes)
 
The Huricane wilma destroyed my house and I had to live with relatives with no computer for a long time. I want to thank you for helping me 2 months ago, but now I cannot get this code to work.

:(
 
Back
Top