Private Sub installFiles()
Dim resFiles() As String = Application.ResourceAssembly.GetManifestResourceNames
For Each resFile As String In resFiles
If resFile.EndsWith("7za.exe") Then
Dim tmpFile As String = IO.Path.Combine(IO.Path.GetTempPath, IO.Path.GetTempFileName)
if ExtractEmbeddedResourcefile then(Application.ResourceAssembly.GetManifestResourceStream(resFile), tmpFile)
debug.writeline(tmpFile) 'do something with the file name here (like start your process)
end if
'delete file when done
IO.File.Delete(tmpFile)
End If
Next
End Sub
Private Function ExtractEmbeddedResourcefile(ByVal resStream As IO.Stream, ByVal OutFilename As String) As Boolean
Try
If IO.File.Exists(OutFilename) Then
IO.File.Delete(OutFilename)
End If
Dim count As Integer = CType(resStream.Length, Integer) - 1
Dim buffer(count) As Byte
resStream.Read(buffer, 0, count + 1)
Using fs As New FileStream(OutFilename, FileMode.Create)
With fs
.Write(buffer, 0, count + 1)
.Flush()
.Close()
End With
End Using
Return CBool(IO.File.Exists(OutFilename))
Catch ex As Exception
Return False
End Try
Return False
End Function