Add any null bytes into file
I'm creating a Console Application
I inserted a "seek" class and i want that it adds8 bytes null (00) in the pointer's position.
I created a Console APplication, i inserted a StreamReader and StreamWriter Class.
And i want also the file that it must have8 bytes null added come drag in console application's icon and the TOol starts and add8 bytes null.
How can i do?
I have also another problem, any Console Application that I create closes in 2 seconds so i want to know if there is a good way for quiting ConsoleApplication clicking a Key of the Keyboard.
Thanks 2 all. :D
in regards to #1 - im not sure
in regards to #2 for the Console Application, just read a key from the keyboard - it will keep waiting for that input before it proceeds to close:
Dim theInput as String = Console.ReadLine()
or maybe
Dim theInput as Integer = Console.Read()
Here's an example:
Public Function OpenByteWrite(ByVal Filespec As String, ByVal Mode As System.IO.FileMode) As ByteIOSB
Static iosb As ByteIOSB
iosb.Astat = 0
iosb.Status = False
OpenByteWrite = iosb
If ((Mode = FileMode.Append) And (Not File.Exists(Filespec))) Then
MsgBox("File: " & Filespec & " doesn't exist", MsgBoxStyle.Information, "OpenByteWrite -No Such File")
Exit Function
End If
If bW IsNot Nothing Then
MsgBox("Stream is already open.", MsgBoxStyle.Information, "OpenByteWrite -FileAlreadyOpen")
OpenByteWrite.Status = False
OpenByteWrite.Astat = IOStatus.cStreamAlreadyOpen
End If
Try
bW = New FileStream(Filespec, Mode)
OpenByteWrite.FileLength = CType(bW.Length, Integer)
OpenByteWrite.Status = True
If Mode = FileMode.Append Then
OpenByteWrite.FilePosition = CType(bW.Length, Integer)
ByteWriterModeIsAppend = True
Else
OpenByteWrite.FilePosition = 0
ByteWriterModeIsAppend = False
End If
ByteReadFileSpec = Filespec
OpenByteWrite.Status = True
OpenByteWrite.Astat = IOStatus.cOperationSuccess
Catch e As Exception
MsgBox("File: " & Filespec & " doesn't exist", MsgBoxStyle.Information, "OpenByteWrite - " & e.Message)
OpenByteWrite.Status = False
OpenByteWrite.Astat = IOStatus.cFileOpenError
End Try
End Function