Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   [urgent newbie] input streams problem with .NET (http://www.go4expert.com/forums/urgent-newbie-input-streams-net-t779/)

kkyeung 3May2006 23:06

[urgent newbie] input streams problem with .NET
 
I'm now doing a project, and what I need to do is firstly read a txt file using i/o stream. I've include the lib and since I need to do it in the .NET form (header) and I want to make it such that when I click the button, it will do the file read-in.
But I cannot add file declaration such things into the header, as there's no main func there. What should I do? Coz I wanna relate the file read-in to the button.
Million thanks!!

coderzone 4May2006 11:22

Re: [urgent newbie] input streams problem with .NET
 
Can you frame your question again. I mean I could not get what you are asking? Are you looking for button click handler to be added or what?

kkyeung 5May2006 00:03

Re: [urgent newbie] input streams problem with .NET
 
I have a form called form1.h, and respectively form1.cpp. I have the following code:
Code: CPP

#include "stdafx.h"
#include "Form1.h"
#include <windows.h>
#include <iostream>
#include <fstream>

using namespace fyp1;

int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
    System::Threading::Thread::CurrentThread->ApartmentState = System::Threading::ApartmentState::STA;

    ifstream iFile("test.txt");


    Application::Run(new Form1());
    return 0;
}

I wanna add ifstream into above so that I can read-in a file, then pass the parameter into Form1(). But how can I do that? (ignore the button problem, i don't need it now)The above code cannot be compiled.
Thanks again.

shabbir 5May2006 07:27

Re: [urgent newbie] input streams problem with .NET
 
Quote:

Originally Posted by kkyeung
I wanna add ifstream into above so that I can read-in a file,

But I see the ifstream is already there.
Quote:

Originally Posted by kkyeung
then pass the parameter into Form1(). But how can I do that?

Create an object of form1 with some other constructor
Quote:

Originally Posted by kkyeung
The above code cannot be compiled.

What error it gives.


All times are GMT +5.5. The time now is 01:44.