How to use file I/o codes with form and controls codes

Discussion in 'ASP .Net' started by Allen, Dec 2, 2007.

  1. Allen

    Allen Guest

    Hi Everybody,

    I would appreciate it if you can give me a hand here.

    I want to use the two codes, below, together to do the following
    when the "IN" button is clicked (InBtn_Click):-

    1- Create (or open) output.txt, and
    2- Type the current time (hour only) in it.

    I tried to include the first code inside the handle function in the second
    code, but it does not work. Can anybody tell me who I am going to work the
    two codes together?

    Each code works fine by itself. The message box inside the
    handler works fine when "IN" button is clicked. The the output.txt file
    open and the current time will be stamped inside it when I use it in a
    different function. But if I put the first code inside the handler function
    of the second code, then, when I click the "IN" button, I would not get what
    I am expecting, Which is to open output.txt and stamp the current time.

    First code:

    FileStream* fs = new FileStream(S"output.txt", FileMode::Create);
    StreamWriter* sw = new StreamWriter(fs);
    String* TimeString = System::DateTime::Now.ToString("HH");
    sw->WriteLine(TimeString);
    sw->Flush();
    sw->Close();

    Second Code:

    private: System::Void InBtn_Click(System::Object * sender,
    System::EventArgs * e)
    {

    // If I put the first code here, output.txt would not be created and current
    time
    //would not be stamped.

    if ( mark == '-')
    {
    MessageBox::Show(" You can't sign in twice! ",S" Error ");
    }
    }


    --
    Thanks
    Allen

    --
    Thanks
    Allen

    --
    Thanks
    Allen
    Allen, Dec 2, 2007
    #1
    1. Advertising

  2. "Allen" <> wrote in message
    news:...

    > MessageBox::Show(" You can't sign in twice! ",S" Error ");



    This appears to be a C++ WinForms app...


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae [MVP], Dec 3, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Greg  --
    Replies:
    4
    Views:
    2,138
  2. Replies:
    2
    Views:
    2,798
    Malcolm
    Aug 20, 2005
  3. Nathan Sokalski
    Replies:
    4
    Views:
    1,136
    Muhammad Naveed Yaseen
    Sep 5, 2007
  4. Ellie
    Replies:
    2
    Views:
    441
    Ellie
    Oct 30, 2008
  5. Replies:
    3
    Views:
    155
    Michael Winter
    Nov 8, 2004
Loading...

Share This Page