The error isCode:#include "stdafx.h" using namespace System; using namespace System::Net; using namespace System::Net::Sockets; using namespace System::IO; using namespace System::Text; void main(void) { Stream^ fS = gcnew FileStream("D:\\TextOut.txt", FileMode::Create, FileAccess::Write); StreamWriter^ sWriter = gcnew StreamWriter(fS); Console::WriteLine("Encoding type : " + sWriter->Encoding->ToString()); Console::WriteLine("Format Provider : " + sWriter->FormatProvider->ToString()); sWriter->WriteLine("Today is {0}", DateTime::Today.DayOfWeek); sWriter->WriteLine("Today we will mostly be using StreamWriter"); for (int i = 0; i < 5; i++) sWriter->WriteLine("Value {0}, its square is {1}", i, i * i); sWriter->Write("Arrays can be written : "); // here if I declare the array as 'array<char>', then comes an error array<System::Char>^ myArray = gcnew array<System::Char>(5) { 'a', 'r', 'r', 'a', 'y' }; sWriter->Write(myArray); sWriter->WriteLine("\r\nAnd parts of arrays can be written too"); // the error comes up here sWriter->Write(myArray, 0, 3); sWriter->Close(); fS->Close(); }
And there is one more thing,Code:error C2664: 'void System::IO::TextWriter::Write(cli::array<Type,dimension> ^,int,int)' : cannot convert parameter 1 from 'cli::array<Type> ^' to 'cli::array<Type,dimension> ^'.
the Write() method for StreamWriter have only four overloads, but in MSDN it shows more than it 17... Why whats wrong here?


Reply With Quote
Marius Bancila
Bookmarks