StreamReader reads, but StreamWriter doesn't write...

C

cagey cretin

I have set up a catch/try deal to find an error, but there are none
reported nor when I clean the build/rebuild. Simple filecalled
text_file.txt. I cannot write to it, but I can write into it with
notepad and read it with StreamReader.

Can anyone show me the error of my ways?

//AppendText() Method
#using <mscorlib.dll>
using namespace System;
void main()
{
bool fileProblem;
//Declare StreamWriter Variable and Create Text File
IO::StreamWriter *outFile;
outFile =
IO::File::AppendText("text_file.txt");
//Close file so error is not reported
outFile->Close();
//Declare variable to assign to text entered
String *line;
//Gather info to write to file
Console::WriteLine("Enter Name:");
line =
Convert::ToString(Console::ReadLine());
try
{
outFile =
IO::File::AppendText("text_file.txt");
}
catch(IO::IOException *ex)
{
fileProblem = true;
Console::WriteLine(ex->Message);
}
if (fileProblem = false)
{
outFile->WriteLine(line);
}
Console::WriteLine("You entered {0}",
line);
outFile->Close();
}
 
A

Armin Zingler

C

Cor

Hi Cagey,

Are you sure you are in the right newsgroup.
The VC group is two three rows higher, on top just above the csharp
newgroup.

I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top