So I have been using FileOpen, FileGet, and FileClose normally in my .net app. However, I was told by a friend that I should be using IO instead as its faster, and is overall better. I have been looking through the docs and I am still a bit confused. Here is my original code for a file binder:
'Opens file1 by user choice and gets contents
FileOpen(1, TextBox1.Text, OpenMode.Binary, OpenAccess.Read, OpenShare.Default)
filein = Space(LOF(1))
FileGet(1, filein)
FileClose(1)
'Opens file2 and gets contents
FileOpen(1, Application.StartupPath & "\file2.exe", OpenMode.Binary, OpenAccess.Read, OpenShare.Default)
file2 = Space(LOF(1))
FileGet(1, file2)
FileClose(1)
'Opens final file that will contain both binded files
FileOpen(1, filename, OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Default)
FilePut(1, file2 & filesplit & filein)
FileClose(1)
I have tried to use IO.File.WriteAllBytes and IO.File.WriteAllText with no luck. How would I go about changing my code around to use IO? Thanks
Here is code that you can use to read the file into a byte array:
to write the byte array to a file: