0

there is fstream in normal C++ that allows you to do file i/o

but how do i do this in managed C++ in a forms application?

i read about a config file but i dont quite get it..

thnx.

2
Contributors
3
Replies
6
Views
7 Years
Discussion Span
Last Post by evilguyme
0

It's been a while since I used managed C++, but I think it was something like:

System::String ^ name = "something.txt";
    System::IO::FileStream ^ fs = System::IO::File::Open(name,System::IO::FileMode::Open);
    // Do stuff
    fs->Close();

But I could be wrong.

Edited by Nick Evan: n/a

0

ahh thnx. lemme try that :)

it works except idk how input and output.. i tried using the system:: things but no luck in finding out how..

Edited by evilguyme: n/a

0

ok i figured out how to input it into the file but a problem remains...

this is what i have got

using namespace System;
using namespace System::Ios;
using namespace System::Ios::Text

void AddText( FileStream^ fs, String^ value )
{
   array<Byte>^info = (gcnew UTF8Encoding( true ))->GetBytes( value );
   fs->Write( info, 0, info->Length );
}


String ^b1Text = button1->Text + "\n";

FileStream ^fs = File::Open(weblinkFile, FileMode::CreateNew|FileMode::Open);

AddText(fs, b1Text);
AddText(fs, button2->Text);

but the thing is that instead of making another line it gives me "Button 1" followed by this weird rectangle shape and then "Button 2" on the same line.

how can i make things come on a new line in the file while using

button1->text

in there.. cuz i can replace button1->text with "Hello World \n" and it creates a new line but it's a probem cuz there's no " " in button1->Text

is there any other way to create a new line using a string in the 2nd param?

Edited by evilguyme: n/a

This article has been dead for over six months. Start a new discussion instead.
Be sure to adhere to our posting rules.