Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


MC++ writing to file

This topic is 5237 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to write to a file like this (translated from a C# example):
#using <mscorlib.dll>
using namespace System;
using namespace System::IO;
using namespace System::Text;

int main()
		FileStream *file = new FileStream(S"test.txt", FileMode::OpenOrCreate);
		StreamWriter *sw = new StreamWriter(file);
		sw->WriteLine(S"Hello World!");
		sw->Write(S"This is a ");
		sw->WriteLine(S"string of characters.");
	catch (IOException *e)
		Console::WriteLine("An IO exception has been thrown!");
		return 1;
	return 0;
The program compiles fine, and when I run it, without the file existing, it gets created but nothing is written to it [edited by - Eriond on May 18, 2004 4:48:22 PM]

Share this post

Link to post
Share on other sites
Try putting a sw->Close(); after your writes. It sounds like your file isn''t getting flushed.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!