how to file handling e.g read and write file ,with window form application in visual studio

Recommended Answers

All 8 Replies

Same as you would do in a console aplication.

ok i try

why this happen help me ddanbe
error C2065: 'string' : undeclared identifier
i also include string library header`

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
            string number;
            number=textBox1->Text;

             MessageBox::Show("Work on it Soon complete");

         }

`

While I cannot be certain, it is likely due to a lack of scoping on the string declaration. The C++ standard string class resides in the std namespace, and you would need to scope the declaration accordingly:

            std::string number;

Alternately, if you expect to have a large number of string objects, you could bring the string class into scope throughout the file:

using std::string;

It is not recommended that you scope the entire namespace with using namespace std;, as this can lead to namespace conflicts. While the namespace-level scoping can be a convenience for small programs, it quickly becomes problematic, so it is best to avoid it unless you are certain it will not cause conflicts, and using in general should never be used in a header file, as it will cascade into any file that the header is included in.

Since you are using C++/CLI, rather than standard C++, you should also be aware that .Net Framework has its own String class, which is not compatible with the C++ standard string class. Most .Net functions expect a String, and won't work with a string.

The String class( remark the capital S) resides in the System namespace, so you don't have to include <string> or use using namespace std;
this will work:

            String^ number;
            number = txtBox->Text;
            MessageBox::Show("Work on it Soon complete");

But as Schol-R-LEA pointed out, I don't think VS C++ is always standard C++.

O, and the strange hat ^ you see after the word String is this.

thankx guys

specially thank you @ ddanbe

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.