I only have one more small question is I have made a textbox in C++ CLR, how can I load text from a text file?
thank you.
Should be
I only have one more small question is I have made a textbox in vb, how can I load text from a text file?
thank you.
Method - System::IO::File::ReadAllLines will read all lines of a file.
using namespace System;
using namespace System::IO;
int main(array<System::String ^> ^args)
{
array<String ^> ^lines=System::IO::File::ReadAllLines("sample.txt");
for(int i=0;i<lines->Length;i++)
Console::WriteLine(lines[i]);
return 0;
}
You may use another method - System::IO::File::ReadAllText to read all lines of a file.
using namespace System;
using namespace System::IO;
int main(array<System::String ^> ^args)
{
String ^str=System::IO::File::ReadAllText("sample.txt");
Console::WriteLine(str);
return 0;
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.