balajicodeit 0 Newbie Poster

Hi,

I have a C++ code which reads a file [vtk file - its similar to text file only]. and try to store it in string.

here's the code:

String^ ParallelProjectionRenderer::GetVolumeDataAsString(String^ FileName)

{
    vtkSmartPointer<vtkDataSetWriter> sWriter = vtkSmartPointer<vtkDataSetWriter>::New();

    String^ FileName = "D:\\Users\\...";

    char * sptName = static_cast<char *>(Marshal::StringToHGlobalAnsi(FileName).ToPointer());

    sWriter->SetFileName(sptName);

    sWriter->Register(nullptr);

    sWriter->SetInput(this->dataSource);

    sWriter->SetFileTypeToASCII();

    sWriter->Write();

    sWriter->Delete();

    String^ result= File::ReadAllText(FileName);   [it breaks here with system.memoryoutofexception when the file size is huge]

    return result;

}

this code executes fine when the file size is less than 8mb.

I wanted to know whats the maximum memory allocated to the string.


As a workaround i skipped reading out in C++ code. and i tried to read the file contents in asp.net C# code and store it on string.

Same sort of exception came.


Basically i need this result in string bcoz, I need to communicate with the Silverlight component.

As far as i know, the WebForm to silverlight communication is done via javascript using string message.

So is there a way for this issue?

Thanx in advance,

Balajee

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.