> How come line 1 will output garbage to the screen, but line 2 will output a
> good number to a file?
What kind of "garbage"? The wrong number? Random characters? An exception?
> How can I make line 1 out put a good number to the screen
>
> String* dayStr = System::DateTime::Now.ToString("dd");
>
> Int32 dayInt = System::Int32::Parse(dayStr);
Why do you create a string and parse it? Why not simply:
Int32 dayInt = System::DateTime::Now::Day;
> Console::WriteLine("the day is {0}", __box(dayInt) ); // Line 1
>
[quoted text clipped - 5 lines]
>
> Int32 day = br->ReadInt32();
You forgot to close the stream here.
> fs = new FileStream(S"_1k.txt", FileMode::Create); //will write the time to
> another file
[quoted text clipped - 3 lines]
> Br->Write( day);
> //Line 2

Signature
Göran Andersson
_____
http://www.guffa.com
Allen Maki - 22 Jul 2007 06:23 GMT
Hi Göran,
I really appreciate your help. I learn a new way to deal with DateTime
which is (Int32 CurHour = System::DateTime::Now.Hour), but now I have a
problem.
Format1(your format): Int32 dayInt = System::DateTime::Now.Day;
Format 2 (The one I use before): Int32 dayInt = System::Int32::Parse(dd);
Int32
CurHour = System::DateTime::Now.Hour;
Now, after I use format 2 instead of format 1, the things went to the
opposite, which is I get garbage (random character) when I write to files
and get good numbers when writing to the screen.
To answer your questions:
Why do you create a string and parse it?
The answer is, that was the only way for me to get good number into the
file.
What kind of "garbage"? The wrong number? Random characters? An exception?
The answer is Before I was getting wrong numbers.
>> How come line 1 will output garbage to the screen, but line 2 will output
>> a good number to a file?
[quoted text clipped - 29 lines]
>>
>> Br->Write( day); //Line 2