你可以参考一下开源的VBCorLib项目,在sourceforge上的下载的地址是http://sourceforge.net/projects/vbcorlib/官方网站是http://www.kellyethridge.com/vbcorlib/如果你不想知道的太多,可以直接注册VBCorLib.dll,其实这个dll实现了很多.Net类库中的功能,比如ArrayList,Hashtable,各种加密算法也是应有尽有 最新版本是2.3下面是其关于Base64编码文件的一段代码'Text1中是一个文件名,测试的数据来看,3.5M左右的文件,Base64编码时间在0.1秒左右 '下面的代码很简单不做解释 ' Encodes a selected file into a Base64 string. Private Sub cmdEncode_Click() ' Lets check if the file exists and let the ' user know if we couldn't find it. If Not File.Exists(Text1.Text) Then MsgBox "File does not exist.", vbExclamation + vbOKOnly, "File Not Found." Exit Sub End If ' We don't want to load large files into memory, so we ' will simply map it into memory. Dim map As MemoryMappedFile Set map = NewMemoryMappedFile(Text1.Text)
' And we will request a Byte array view of the mapped file. Dim view() As Byte view = map.CreateView
' We want to be cautious when we have a view of the mapped ' file, because we don't really own the Byte view. It is ' being loaned to us and we need to give it back, or bad ' things will happen. On Error GoTo errTrap
' Create our timing object to tell us how long it took to encode. Dim sw As StopWatch Set sw = StopWatch.StartNew
' Encode the file using our mapped view. Even though ' the entire file is not loaded into memory, a mapped view ' of a file is still extremely fast. Dim s As String s = Convert.ToBase64String(view, , , True)
' let the world know how long the encoding took. lblTime.Caption = sw.ElapsedMilliseconds
' And show other stats about the file and encoded string. lblFileLength = FileLen(Text1.Text) lblEncodedLength.Caption = Len(s)
' Finally show the encoded string in the textbox. RichTextBox1.Text = s
errTrap: ' We have to delete the view we have borrowed before ' we close the mapped file, always. map.DeleteView view map.CloseFile End Sub
截屏生成的图片要转换为字节组然后base64编码生成字符串,当截屏的区域过大时,图片进行base64编码的时间很久
请问有谁做过这样的功能的,如何解决base64编码的时间长的问题?
http://blog.csdn.net/KiteGirl/archive/2006/06/26/834851.aspx
最新版本是2.3下面是其关于Base64编码文件的一段代码'Text1中是一个文件名,测试的数据来看,3.5M左右的文件,Base64编码时间在0.1秒左右
'下面的代码很简单不做解释
' Encodes a selected file into a Base64 string.
Private Sub cmdEncode_Click()
' Lets check if the file exists and let the
' user know if we couldn't find it.
If Not File.Exists(Text1.Text) Then
MsgBox "File does not exist.", vbExclamation + vbOKOnly, "File Not Found."
Exit Sub
End If ' We don't want to load large files into memory, so we
' will simply map it into memory.
Dim map As MemoryMappedFile
Set map = NewMemoryMappedFile(Text1.Text)
' And we will request a Byte array view of the mapped file.
Dim view() As Byte
view = map.CreateView
' We want to be cautious when we have a view of the mapped
' file, because we don't really own the Byte view. It is
' being loaned to us and we need to give it back, or bad
' things will happen.
On Error GoTo errTrap
' Create our timing object to tell us how long it took to encode.
Dim sw As StopWatch
Set sw = StopWatch.StartNew
' Encode the file using our mapped view. Even though
' the entire file is not loaded into memory, a mapped view
' of a file is still extremely fast.
Dim s As String
s = Convert.ToBase64String(view, , , True)
' let the world know how long the encoding took.
lblTime.Caption = sw.ElapsedMilliseconds
' And show other stats about the file and encoded string.
lblFileLength = FileLen(Text1.Text)
lblEncodedLength.Caption = Len(s)
' Finally show the encoded string in the textbox.
RichTextBox1.Text = s
errTrap:
' We have to delete the view we have borrowed before
' we close the mapped file, always.
map.DeleteView view
map.CloseFile
End Sub