Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15458

Change “Open For Binary Access” with Private Types to something with Unicode support

$
0
0
Hi,

I’m looking for some support/suggestions on transitioning my “Open … For Binary Access” approach, to one that supports Unicode characters in path and filename.

One of the features in my app saves data plus a thumbnail in a binary file using the following code:

Code:

Dim PPB As New PropertyBag
Dim oStdPicture As stdPicture
Dim lFileNumber As Long

lFileNumber = FreeFile
Open sFullFileName For Binary Access Write As #lFileNumber

Put #lFileNumber, 1, MyPrivateType1
Set oStdPicture = frmMain.picCanvas.Image
PPB.WriteProperty ("Picture"), oStdPicture
Put #lFileNumber, , PPB.Contents
Put #lFileNumber, , MyPrivateType2

Close #lFileNumber

(To simplify the code, I’ve left out the definition and population of the private types.)

Then, to read the data from the file, it’s using this code:

Code:

Dim PPB As New PropertyBag
Dim oStdPicture As stdPicture
Dim lFileNumber As Long

lFileHandle = FreeFile       
Open sPath & sFile For Binary Access Read As #lFileHandle

Get #lFileHandle, 1, MyPrivateType1
Get #lFileHandle, , varBlob
PPB.Contents = varBlob
Set oStdPicture = PPB.ReadProperty(("Picture"), Nothing)
Get #lFileHandle, , MyPrivateType2

Close #lFileNumber

As part of making my app fully “Unicode aware”, I realized that the “Open … For Binary Access” function, doesn’t support e.g. Thai or Russian characters in the filename or path if you’re running e.g. an English Windows.

For other parts of the app I’m using the ADODB Stream to load the full file in memory, and then process it line by line, but I have no idea how to deal with the Private Types and thumbnail blob in this case.

All suggestions are welcome and much appreciated!

Thanks,
Erwin

Viewing all articles
Browse latest Browse all 15458

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>