Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Two functions into one
Message
From
27/06/2006 11:56:52
 
 
To
27/06/2006 11:48:36
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01131998
Message ID:
01132058
Views:
13
>myString = BitConverter.ToString(loByte)
>
>PS: Sorry not this one. Hang on:)
>
>
>Private Function UnicodeBytesToString( _
>    ByVal bytes() As Byte) _
>    As String
>
>    Return System.Text.Encoding.Unicode.GetString(bytes)
>End Function
>
Based on that, if I use this:
        Dim lcText As String = ""
        lcText = FileToStr("D:\Logo.jpg")
        MessageBox.Show(lcText.Length.ToString)
        oApp.CreateFile(lcText, "D:\Logo2.jpg")

    End Sub

    ' FileToStr() VFP equivalent
    ' expC1 File name
    Public Function FileToStr(ByVal tcFileName As String) As String
        Dim loBinaryReader As IO.BinaryReader
        Dim loByte() As Byte
        Dim loFileStream As IO.FileStream
        Dim lcString As String = ""
        Try
            loFileStream = New IO.FileStream(tcFileName, FileMode.Open, FileAccess.Read)
            loBinaryReader = New IO.BinaryReader(loFileStream)
            loByte = loBinaryReader.ReadBytes(CType(loFileStream.Length, Integer))
            lcString = UnicodeBytesToString(loByte)
            loBinaryReader.Close()
            loFileStream.Close()
        Catch loError As Exception
            System.Windows.Forms.MessageBox.Show(loError.Message)
            lcString = ""
        End Try
        Return lcString
    End Function

    Private Function UnicodeBytesToString(ByVal bytes() As Byte) As String
        Return System.Text.Encoding.Unicode.GetString(bytes)
    End Function
My logo.jpg is 35k. After the conversion back Logo2.jpg, I end up with a 17k file.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform