S
Sara
Hello,
I am new to vbnet and have only worked with text files thus far. I've
converted the ENC() & Encode() calls from this function already. Any
help would be much appreciated.
=========
Private Sub uuencode(ByVal filename1 As String, ByVal filename2 As String)
Dim portion_size As Integer
portion_size = 45
'open the original file as binary read
Open (filename1) For Binary Access Read Shared As #1
'open the target file as binary write
Open (filename2) For Binary Access Write As #2
'for standard uuencode compatibility
Put #2, , "begin 644 " + plain_filename(filename1) + vbCrLf
'total number of full sized portion with "portion_size" bytes
total = LOF(1) \ portion_size
'remain hold the remaining bytes toward end of file
remain = LOF(1) Mod portion_size
'prepare instring to read "portion_size" bytes at a time
instring = String(portion_size, 0)
'current file position
current = 1
'for loop to read the portion one by one
For i = 1 To total
Get #1, current, instring
'use the ENC() for standard uuencode compatibility, pad "M"
Put #2, , ENC(portion_size) + Encode(instring) + vbCrLf
current = current + portion_size
Next
instring = String(remain, 0)
'get the remaining bytes toward end of the file
Get #1, current, instring$
'get the remaining bytes size and calculate ENC() for the last line
Put #2, , ENC(LOF(1) - current + 1) + Encode(instring) + vbCrLf
Close #1
'put "end" for standard uuencode compatibility
Put #2, , ENC(0) + vbCrLf + "end" + vbCrLf
Close #2
End Sub
I am new to vbnet and have only worked with text files thus far. I've
converted the ENC() & Encode() calls from this function already. Any
help would be much appreciated.
=========
Private Sub uuencode(ByVal filename1 As String, ByVal filename2 As String)
Dim portion_size As Integer
portion_size = 45
'open the original file as binary read
Open (filename1) For Binary Access Read Shared As #1
'open the target file as binary write
Open (filename2) For Binary Access Write As #2
'for standard uuencode compatibility
Put #2, , "begin 644 " + plain_filename(filename1) + vbCrLf
'total number of full sized portion with "portion_size" bytes
total = LOF(1) \ portion_size
'remain hold the remaining bytes toward end of file
remain = LOF(1) Mod portion_size
'prepare instring to read "portion_size" bytes at a time
instring = String(portion_size, 0)
'current file position
current = 1
'for loop to read the portion one by one
For i = 1 To total
Get #1, current, instring
'use the ENC() for standard uuencode compatibility, pad "M"
Put #2, , ENC(portion_size) + Encode(instring) + vbCrLf
current = current + portion_size
Next
instring = String(remain, 0)
'get the remaining bytes toward end of the file
Get #1, current, instring$
'get the remaining bytes size and calculate ENC() for the last line
Put #2, , ENC(LOF(1) - current + 1) + Encode(instring) + vbCrLf
Close #1
'put "end" for standard uuencode compatibility
Put #2, , ENC(0) + vbCrLf + "end" + vbCrLf
Close #2
End Sub