User269602965 posted
Put in a Console App and give it a test
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.IO
Module Module1
Sub Main(args As String())
If args.Length <> 3 Then
Console.WriteLine("usage: UnixDosConvert <convertpattern> <infilename> <outfilename> ")
Console.WriteLine(" convertpattern can be UNIX2DOS or DOS2UNIX")
Return
End If
Dim byteCount As Long
Dim b As Byte
Dim fileInfo As New FileInfo(args(1))
Select Case args(0)
Case "UNIX2DOS"
Using inFs As New FileStream(args(1), FileMode.Open)
Using br As New BinaryReader(inFs)
Using outFs As New FileStream(args(2), FileMode.Create)
Using bw As New BinaryWriter(outFs)
For byteCount = 0 To fileInfo.Length - 1
b = br.ReadByte()
If b = 10 Then
bw.Write(CByte(13))
bw.Write(CByte(10))
Else
bw.Write(b)
End If
Next
End Using
End Using
End Using
End Using
Case "DOS2UNIX"
Using inFs As New FileStream(args(1), FileMode.Open)
Using br As New BinaryReader(inFs)
Using outFs As New FileStream(args(2), FileMode.Create)
Using bw As New BinaryWriter(outFs)
For byteCount = 0 To fileInfo.Length - 1
b = br.ReadByte()
If b = 13 Then
' do nothing '
ElseIf b = 10 Then
bw.Write(CByte(10))
Else
bw.Write(b)
End If
Next
End Using
End Using
End Using
End Using
End Select
End Sub
End Module