将文件转换成二进制数组代码(根据目标尺寸自动切割,以QQ邮箱为例):
'If filesize > 4 * 1024 * 1024 Then
'Dim filecount As Integer = Int(filesize / (4 * 1024 * 1024)) + 1
'My.Forms.切割文件.ProgressBar2.Maximum = filecount
'My.Forms.切割文件.ProgressBar2.Minimum = 0
Dim filebyte As Int64 = 0
Dim coventfile As coventfile = New coventfile
Dim filebytes() As Byte = coventfile.File2Bytes(filepath)
My.Forms.切割文件.Show()
'For i As Integer = 0 To filecount
'My.Forms.切割文件.ProgressBar2.Value = i + 1
My.Forms.切割文件.ProgressBar1.Maximum = filebytes.Length
My.Forms.切割文件.ProgressBar1.Minimum = 0
Dim sw As System.IO.StreamWriter
sw = IO.File.CreateText("F:\space craft\火\文件传输尺寸限制终结者(邮件版)\切割文件1.txt")
'sr = IO.File.CreateText("F:\space craft\火\文件传输尺寸限制终结者(邮件版)\切割文件" & i + 1 & ".txt")
For Each bit As Byte In filebytes
My.Forms.切割文件.ProgressBar1.Value = filebyte
sw.Write(bit)
filebyte += 1
Next
sw.Close()
'Next
MsgBox("文件切割成功!!!")
'End If
'If filesize > 4 * 1024 * 1024 Then
'Dim filecount As Integer = Int(filesize / (4 * 1024 * 1024)) + 1
'My.Forms.切割文件.ProgressBar2.Maximum = filecount
'My.Forms.切割文件.ProgressBar2.Minimum = 0
Dim filebyte As Int64 = 0
Dim coventfile As coventfile = New coventfile
Dim filebytes() As Byte = coventfile.File2Bytes(filepath)
My.Forms.切割文件.Show()
'For i As Integer = 0 To filecount
'My.Forms.切割文件.ProgressBar2.Value = i + 1
My.Forms.切割文件.ProgressBar1.Maximum = filebytes.Length
My.Forms.切割文件.ProgressBar1.Minimum = 0
Dim sw As System.IO.StreamWriter
sw = IO.File.CreateText("F:\space craft\火\文件传输尺寸限制终结者(邮件版)\切割文件1.txt")
'sr = IO.File.CreateText("F:\space craft\火\文件传输尺寸限制终结者(邮件版)\切割文件" & i + 1 & ".txt")
For Each bit As Byte In filebytes
My.Forms.切割文件.ProgressBar1.Value = filebyte
sw.Write(bit)
filebyte += 1
Next
sw.Close()
'Next
MsgBox("文件切割成功!!!")
'End If