1

let's say i did add some exe file to the project's resources. now if i want to run that file, i have to extract it from the resources as a new file and then i can run it So please can someone help me with how to do it

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
Hamada Mido
  • 383
  • 5
  • 14

1 Answers1

0

Getting a resource as a stream from an assembly:

myAssembly.GetManifestResourceStream("TheNameSpacename.NameOfYourFile")

Copying the stream to a file: already described here:

 http://stackoverflow.com/questions/411592/how-do-i-save-a-stream-to-a-file

(example is in C#, porting to VB.NET should be easy).

Running the file: use System.Diagnostics.Process.Start:

 http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx
Doc Brown
  • 19,739
  • 7
  • 52
  • 88
  • Thanks but can u discrip what "TheNameSpacename" is ? – Hamada Mido Nov 18 '10 at 18:26
  • Dim appStream As Stream = System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream("Me.Resources.GetHTMLsource.exe") Dim inStream As New StreamReader(appStream) Dim encoding As New System.Text.ASCIIEncoding Dim bytes = encoding.GetBytes(inStream.ReadToEnd) My.Computer.FileSystem.WriteAllBytes("GetHTMLsource.exe", bytes, False) this is what i wirte but the "appstream" is always NULL – Hamada Mido Nov 18 '10 at 18:34
  • TheNameSpace must be the default namespace of your assembly. Look here http://www.jelovic.com/articles/resources_in_visual_studio.htm for an explanation. If you have to analyse an existing assembly regarding its namespace, I suggest using .NET reflector (http://www.red-gate.com/products/reflector/) – Doc Brown Nov 18 '10 at 19:15