I have a part of my code that's supposed to extract an embedded source to a temp folder.
Sub Main()
Dim temp As String
temp = Path.GetTempPath()
Console.WriteLine(temp)
ExtractResourceToDisk("FileExtract.file.exe", temp & "file.exe")
Process.Start(temp & "file.exe")
End Sub
Public Function ExtractResourceToDisk(ByVal ResourceName As String, ByVal FileToExtractTo As String) As Boolean
Dim s As System.IO.Stream = System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream(ResourceName)
Dim ResourceFile As New System.IO.FileStream(FileToExtractTo, IO.FileMode.Create)
Console.WriteLine(s.Length)
Dim b(s.Length) As Byte
s.Read(b, 0, s.Length)
ResourceFile.Write(b, 0, b.Length - 1)
ResourceFile.Flush()
ResourceFile.Close()
ResourceFile = Nothing
End Function
However, I'm getting an "Object reference not set to an instance of an object" error on the line "Dim b(s.Length) As Byte" when I try to run.