IAL32

LanciaFileMemoria

Jul 14th, 2012
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.96 KB | None | 0 0
  1. Imports System.IO
  2. Imports System.Reflection
  3.  
  4. Private Shared Sub Main()
  5.     RunInternalExe("ApplicazioneInterna.exe")
  6. End Sub
  7.  
  8. Private Shared Sub RunInternalExe(exeName As String)
  9.     'Ottieni l'assembly
  10.     Dim assembly__1 As Assembly = Assembly.GetExecutingAssembly()
  11.  
  12.     'Ottieni il nome della cartella dov'è contenuto l'exe
  13.     Dim rootName As String = assembly__1.GetName().Name
  14.  
  15.     'Ottieni la Resource Stream
  16.     Dim resourceStream As Stream = assembly__1.GetManifestResourceStream(rootName + "." + exeName)
  17.  
  18.     'Verifica se il file interno esiste
  19.     If resourceStream Is Nothing Then
  20.         Return
  21.     End If
  22.  
  23.     'Leggi i bytes piani del file
  24.     Dim resourcesBuffer As Byte() = New Byte(resourceStream.Length - 1) {}
  25.  
  26.     resourceStream.Read(resourcesBuffer, 0, resourcesBuffer.Length)
  27.     resourceStream.Close()
  28.  
  29.     'Carica i bytes come un'assembly
  30.     Dim exeAssembly As Assembly = Assembly.Load(resourcesBuffer)
  31.  
  32.     'Esegui l'assembly
  33.     exeAssembly.EntryPoint.Invoke(Nothing, Nothing)
  34. End Sub
Advertisement
Add Comment
Please, Sign In to add comment