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 8678179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:38:56+00:00 2026-06-12T20:38:56+00:00

I am a C++ developer and recently shifted to the world of WPF C#.

  • 0

I am a C++ developer and recently shifted to the world of WPF C#. I am developing an app where I have to load a textfile by using a fileopendialog, select the file and save it in combobox then on clicking writebutton I should perform some operations using the data present in the textfile.

I had done it in C++ as follows:

if(button == m_writeButton)
{
    // get the data from the file
    File m_binFile = m_fileChoice->getCurrentFile();
    MemoryBlock m_data;

    m_binFile.loadFileAsData(m_data);
    size_t blockSize = m_data.getSize();

    unsigned char *f_buffer;
    f_buffer = (unsigned char *)m_data.getData();
    unsigned cnt = 0;

    // Some code
}

I did it in C# as follows:

<ComboBox Name="WriteFileCombo" >
                        <ComboBoxItem Content="Firmware To Download" />
                        <ComboBoxItem Content="{Binding FirmwarePath}" />
</ComboBox>
<Button Content="..." Command="{Binding Path=WriteFilePathCommand}" Name="FileDialogBtn"/>                       

<Button Content="Write File" Command="{Binding Path=WriteFileCommand}" Name="WriteFileBtn" />

View Model class:

private string _selectedFirmware;
    public string FirmwarePath
    {
        get { return _selectedFirmware; }
        set
        {
            _selectedFirmware = value;
            OnPropertyChanged("FirmwarePath");
        }
    }

// Gets called when Browse Button (...) is clicked
private void ExecuteWriteFileDialog()
    {
        var dialog = new OpenFileDialog { InitialDirectory = _defaultPath };
        dialog.DefaultExt = ".txt";
        dialog.Filter = "TXT Files (*.txt)|*.txt";
        dialog.ShowDialog();
        FirmwarePath = dialog.FileName;

        WriteFileCommandExecuted();
    }

// Gets called when Write Button is clicked
public void WriteFileCommandExecuted()
    {
      // same logic as in c++
    }

How do I perform the same operation which is done in C++ code in my WriteFileCommandExecuted() method?

Please 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-12T20:38:58+00:00Added an answer on June 12, 2026 at 8:38 pm
    //Inside void WriteFileCommandExecuted()
    
     System.IO.StreamReader sr = new System.IO.StreamReader("File Path");
                    textBox1.Text =  sr.ReadToEnd();
    
            //Or if you need more control
    
            System.IO.FileStream fs = new System.IO.FileStream(FirmwarePath, System.IO.FileMode.CreateNew);
            System.IO.StreamReader sr = new System.IO.StreamReader(fs);
            string textdata = sr.ReadToEnd();
            int fileSize = (int)new System.IO.FileInfo(FirmwarePath).Length;
    
            Byte f_buffer = new Byte();
            f_buffer = Convert.ToByte(textdata);
            int cnt = 0;
    
        //The FirmwarePath is the path returned to you by your file dialog box.
        //If you want to write the class you will need to instantiate is System.IO.StreamWriter then //invoke the "write" method
    
    • 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 have recently shifted to C#. I am developing
I am a .Net developer but recently shifted to PHP world. I have worked
I am a c++ developer and recently shifted to this amazing WPF world. I
I am a c++ developer and recently shifted to C#. I am developing a
I am developing a WPF application. I am basically a C++ developer and have
I am a C++ developer and recently started working on C# WPF app. I
Iam a web-developer and recently i have completed and launched a website (im using
I am a C++ developer and i recently shifted to C# WPF. I am
I recently inherited an iPhone app. The original developer did not understand memory management
I am an android app developer, recently I am trying to learn Marmalade to

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.