Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. TextBox File Open

TextBox File Open

Scheduled Pinned Locked Moved C / C++ / MFC
questioncomhelptutorial
2 Posts 2 Posters 18 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Robert Johnson 2023
    wrote on last edited by
    #1

    0

    I need to read the TextBox input, my username and password work as below, but the file input and file output require another step to convert a string that can open the files.

    I've tried every example I can find, cstring numerous times.I can't believe no one uses a textbox to open a file. Why can't i get an answer? Will someone please read this question and answer it. I see that some questions get numerous answers and I can't even get one answer. Please help me!

    THESE 2 BELOW WORK private: System::Void usernameTextBox_TextChanged(System::Object^ sender, System::EventArgs^ e) { msclr::interop::marshal_context context; std::string myUsername = context.marshal_asstd::string(usernameTextString); }

    private: System::Void passwordTextBox_TextChanged(System::Object^ sender, System::EventArgs^ e) {
    msclr::interop::marshal_context context;
    std::string myPassword = context.marshal_as(passwordTextString);
    }
    THESE 2 BELOW NEED AN ADDITIONAL LINE OF CODE TO OPEN THE FILES private: System::Void myInfileTextBox_TextChanged(System::Object^ sender, System::EventArgs^ e) { msclr::interop::marshal_context context; std::string myInfile = context.marshal_asstd::string(myInfileTextString); }

    private: System::Void myOutfileTextBox_TextChanged(System::Object^ sender, System::EventArgs^ e) {
    msclr::interop::marshal_context context;
    std::string myOutfile = context.marshal_as(myOutfileTextString);
    }

    L 1 Reply Last reply
    0
    • R Robert Johnson 2023

      0

      I need to read the TextBox input, my username and password work as below, but the file input and file output require another step to convert a string that can open the files.

      I've tried every example I can find, cstring numerous times.I can't believe no one uses a textbox to open a file. Why can't i get an answer? Will someone please read this question and answer it. I see that some questions get numerous answers and I can't even get one answer. Please help me!

      THESE 2 BELOW WORK private: System::Void usernameTextBox_TextChanged(System::Object^ sender, System::EventArgs^ e) { msclr::interop::marshal_context context; std::string myUsername = context.marshal_asstd::string(usernameTextString); }

      private: System::Void passwordTextBox_TextChanged(System::Object^ sender, System::EventArgs^ e) {
      msclr::interop::marshal_context context;
      std::string myPassword = context.marshal_as(passwordTextString);
      }
      THESE 2 BELOW NEED AN ADDITIONAL LINE OF CODE TO OPEN THE FILES private: System::Void myInfileTextBox_TextChanged(System::Object^ sender, System::EventArgs^ e) { msclr::interop::marshal_context context; std::string myInfile = context.marshal_asstd::string(myInfileTextString); }

      private: System::Void myOutfileTextBox_TextChanged(System::Object^ sender, System::EventArgs^ e) {
      msclr::interop::marshal_context context;
      std::string myOutfile = context.marshal_as(myOutfileTextString);
      }

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I am not sure what you mean by "use a textbox to open a file", but all you need is the actual path to the file. There is example C++/CLI code at File.Open Method (System.IO) | Microsoft Learn[^].

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups