using namespace System::IO;

Read Bytes From A File

	__int64 FileByteNumber;
	int ReadByte;

	FileStream ^SourceFile = gcnew FileStream(SelectFileDialog->FileName, FileMode::Open, FileAccess::Read, FileShare::None);

	for (FileByteNumber = 0; FileByteNumber < SourceFile->Length; FileByteNumber++)
		//----- READ EACH BYTE -----
		if ((ReadByte = SourceFile->ReadByte()) == -1)
			throw gcnew Exception("File read too short");

		//ReadByte has the value but is actually an integer

Overwrite Bytes In A File As Its Read


To move back 1 byte before writing:

Read String From A File

	if (File::Exists(TemporaryDirectory + EXTERNAL_EXPORTER_STATUS_FILE))
		StreamReader ^StreamReader1 = gcnew StreamReader(TemporaryDirectory + EXTERNAL_EXPORTER_STATUS_FILE);
		MyString = StreamReader1->ReadToEnd();




We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.


Your email address will not be published.