Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to convert .zip file into string
Message
From
02/05/2008 10:32:29
 
 
To
02/05/2008 06:44:00
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01306186
Message ID:
01314783
Views:
12
>Hi Bruce,
>
>I decided to try out your method to mentioned. I am trying to use the BinaryReader class to achieve what you mentioned am i headed in the right direction. Is it possible for you to provide me with a small sample code. I will be very greatful. Thanks for your help.
>
>Regards,
>Bilal.

Hi Bilal,

Take a look at Convert.ToBase64String Method in VB.Net docs. Their example:
Public Sub EncodeWithString()
   Dim inFile As System.IO.FileStream
   Dim binaryData() As Byte

   Try
      inFile = New System.IO.FileStream(inputFileName, _
                                        System.IO.FileMode.Open, _
                                        System.IO.FileAccess.Read)
      ReDim binaryData(inFile.Length)
      Dim bytesRead As Long = inFile.Read(binaryData, _
                                          0, _
                                          inFile.Length)
      inFile.Close()
   Catch exp As System.Exception
      ' Error creating stream or reading from it.
      System.Console.WriteLine("{0}", exp.Message)
      Return
   End Try

   ' Convert the binary input into Base64 UUEncoded output.
   Dim base64String As String
   Try
      base64String = System.Convert.ToBase64String(binaryData, _
                                                   0, _
                                                   binaryData.Length)
   Catch exp As System.ArgumentNullException
      System.Console.WriteLine("Binary data array is null.")
      Return
   End Try

   ' Write the UUEncoded version to the output file.
   Dim outFile As System.IO.StreamWriter
   Try
      outFile = New System.IO.StreamWriter(outputFileName, _
                                           False, _
                                           System.Text.Encoding.ASCII)
      outFile.Write(base64String)
      outFile.Close()
   Catch exp As System.Exception
      ' Error creating stream or writing to it.
      System.Console.WriteLine("{0}", exp.Message)
   End Try
End Sub
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform