Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9005115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:03:44+00:00 2026-06-16T01:03:44+00:00

Under windows, when Evernote is installed, an api is also installed, which can be

  • 0

Under windows, when Evernote is installed, an api is also installed, which can be accessed through vba (for example).

Each notes can show its “Resources” (attached files and images), and the actual Resources can be retrieved as Byte Arrays.

I have trouble writing the byte arrays to actual file.

Declaration of variables :

Dim fileByte() As Byte
Dim nt As enapiLib.Note

Fetch data :

fileByte = nt.Resources.Item(i).Data

Write byte array to a file :

Function WriteByteArray(vData As Variant, sFileName As String, Optional bAppendToFile As Boolean = False) As Boolean
Dim iFileNum As Integer, lWritePos As Long

Debug.Print " --> Entering WriteByteArray function with " & sFileName & " file to write."
On Error GoTo ErrFailed
If bAppendToFile = False Then
    If Len(Dir$(sFileName)) > 0 And Len(sFileName) > 0 Then
        'Delete the existing file
        VBA.Kill sFileName
    End If
End If

iFileNum = FreeFile
Debug.Print "iFileNum = " & iFileNum
'Open sFileName For Binary Access Write As #iFileNum
Open sFileName For Binary Lock Read Write As #iFileNum

If bAppendToFile = False Then
    'Write to first byte
    lWritePos = 1
Else
    'Write to last byte + 1
    lWritePos = LOF(iFileNum) + 1
End If

Put #iFileNum, lWritePos, vData
Close #iFileNum

WriteByteArray = True
Exit Function

ErrFailed:
Debug.Print "################################"
Debug.Print "Error handling of WriteByteArray"
Debug.Print "################################"
FileWriteBinary = False
Close iFileNum
Debug.Print Err.Description & "(" & Err.Number & ")"
End Function

I tried with an exe file

By debug.printing each byte value, I know that my byte array starts with 4D 5A as every other exe file

Resource (1) : 
ClickToSetup.0.9.8.1416.exe
application/x-msdownload
Le fichier C:\Dropbox\TestEvernote\ClickToSetup.0.9.8.1416.exe doit être créé.
Lbound(fileByte) = 0
Ubound(fileByte) = 5551919
i = 0
filebyte(i) = 4D
i = 1
filebyte(i) = 5A

By reading back the exe file created to a byte array, I know that the newly created array starts with byte 4D 5A as wished

But the exe file present on the hard drive is _corrupted_, and _does not start_ with the correct bytes_ :

Here are the first binary values of the stored file on the harddrive : (got from VBinDiff tool ) (I cannot post image, I am a newbie here… ) : VBinDiff output of exe

Why is there these 12 bytes in front of the actual data ??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:03:45+00:00Added an answer on June 16, 2026 at 1:03 am

    I had the same problem – some 12 byte header thrown at the top of every file written. It turns out that the PUT command doesn’t quite know how to handle data of type Variant. I’m not sure of the exact cause, but my work around was to simply replace the PUT line:

        Put #iFileNum, lWritePos, vData
    

    with this:

        Dim buffer() As Byte
        buffer = vData
        Put #iFileNum, lWritePos, buffer
    

    Problem solved.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have installed android sdk under Windows 7. But when I run it, I
Under Windows I installed MinGW and Eclipse, and created a new C++ project with
Under windows 7, I can not use default port 80, so 81 instead. I
Under Windows XP WPF true 3D content (which is usually displayed using the Viewport3D
I need a tail utility that works under windows and can monitor file on
Which X11 forwarding under Windows solution do you recommmend ? I'd like to get
How can I run linux binary under windows? Is there some emulation jar or
How can I emulate iPad browser under windows? I know user agent string and
I am programing under windows, c++, mfc How can I know disk's format by
I am running my code in R (under Windows) which involves a lot of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.