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

  • SEARCH
  • Home
  • 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 8776847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:09:07+00:00 2026-06-13T19:09:07+00:00

I am a C++ developer and recently started working on C# WPF app. I

  • 0

I am a C++ developer and recently started working on C# WPF app. I am following MVVM. Well I am working on Combobox and buttons. Basically I have a browse button to load a binfile and store it in combobox and when I click TEST button, i should read the data present in file, get the size of it.

Here is the XAML:

<ComboBox Name="ClockYHZBox" >              
          <ComboBoxItem Content="{Binding FirmwarePath}" />
</ComboBox>
<Button Content="Browse" Command="{Binding WriteFilePathCommand}" Name="RunPCMPDM0" />

<Button Content="Test" Command="{Binding WriteDataTestCommand}" />

ViewModel Class:

private string _selectedFirmware;
    public string FirmwarePath
    {
        get; set;
    }

// This method gets called when BROWSE Button is pressed
private void ExecuteWriteFileDialog()
    {
        var dialog = new OpenFileDialog { InitialDirectory = _defaultPath };
        dialog.DefaultExt = ".bin";
        dialog.Filter = "BIN Files (*.bin)|*.bin";
        dialog.ShowDialog();
        FirmwarePath = dialog.FileName; // Firmware path has the path           
    }       

// Method gets called when TEST Button is Pressed
public void mSleepTestCommandExecuted()
    {
        int cmd = (22 << 8) | 0x06; 
        System.IO.StreamReader sr = new System.IO.StreamReader(FirmwarePath);

        string textdata = sr.ReadToEnd();
        int fileSize = (int)new System.IO.FileInfo(FirmwarePath).Length;

        Byte[] buffer = new Byte[256];            

        // This gives me the size and data, But i am failing to do
        // further operation of storing value in BUFFER
        // and MEMCPY which is shown below in C++ Code          
    }

This is how I had done in my C++ application:

MemoryBlock binFile;
m_wdbFile->getCurrentFile().loadFileAsData(binFile); //m_wbdFile is a filedialog object
BYTE *buffer = NULL;
int  fileSize = binFile.getSize();
buffer = (BYTE *)calloc(sizeof(BYTE), fileSize + 2);    
memcpy(buffer+2, binFile.getData(), fileSize);

As you can see above, it opens the file, stores the size in fileSize, allocates block of memory to buffer and so on. How can I achieve it? I would appreciate your help 🙂

  • 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-13T19:09:09+00:00Added an answer on June 13, 2026 at 7:09 pm
    byte[] b;
    FileStream fileStream=new FileStream(FirmwarePath,FileMode.Open);
    using (BinaryReader br = new BinaryReader(fileStream))
    {
       b = br.ReadBytes(fileSize);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a C++ developer and recently started working on WPF. Well I am
I am a C++ developer and have recently started learning WPF. I am working
I am a C++ developer and recently started working on WPF. I am sorry
I`m an Android developer, and recently started working on JAVA PC project for client.
I'm a junior developer and recently started working for a very small office where
Recently I have started working with Codeigniter framework in order to develop RESTFul web
I have recently started my job as web application backend developer. I am bit
I have recently started working on some open source project which I found relevant
I have recently started working with Drupal on the side and have had to
I have recently started working for a new company and am now working on

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.