Click here to Skip to main content
15,919,613 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
QuestionBase class pointer to derived class object??? Pin
Ash2015-Oct-07 20:18
Ash2015-Oct-07 20:18 
AnswerRe: Base class pointer to derived class object??? Pin
Christian Graus15-Oct-07 23:12
protectorChristian Graus15-Oct-07 23:12 
Answerit's called polymorphism Pin
etkid8417-Oct-07 2:38
etkid8417-Oct-07 2:38 
QuestionStreamReader, StreamWriter and File Position? Pin
BuckBrown15-Oct-07 9:18
BuckBrown15-Oct-07 9:18 
QuestionRe: StreamReader, StreamWriter and File Position? Pin
Mark Salsbery15-Oct-07 9:44
Mark Salsbery15-Oct-07 9:44 
AnswerRe: StreamReader, StreamWriter and File Position? Pin
BuckBrown15-Oct-07 10:17
BuckBrown15-Oct-07 10:17 
GeneralRe: StreamReader, StreamWriter and File Position? [modified] Pin
Mark Salsbery15-Oct-07 11:02
Mark Salsbery15-Oct-07 11:02 
GeneralRe: StreamReader, StreamWriter and File Position? Pin
BuckBrown16-Oct-07 9:05
BuckBrown16-Oct-07 9:05 
Hi Mark,

This has been exhibiting some real strange behavoir. I have seen my output begin writing at position 0 as it should after a fileStream->Position = 0, and then I have seen it begin writing at approximately position 100 (when I designated position 0). As I try to debug this problem something seems to "magically" change where position 0 actually is and will stay that way for half an hour and then change to some other position when I designate position 0. If I start with no file existing then the file is created and the following written into it...

[Line Test]
[OVP Test]
[SCP Test]
[UVLO Test]

After that I...

fileStream->Position = 0;
for(int index = 0; index < 3; index++)
{
string = streamReader->ReadLine();
streamWriter->WriteLine(string + "X"); // Notice the appended X
}

And the output looks like...

[Line Test]
[OVP Test]
[SCP Test]
[UVLO Test]
[Line Test]X
[OVP Test]X
[SCP Test]X
[UVLO Test]X

Which is not what I was expecting. Change the above code by one line to set the position to the begining of the file before each streamWriter->WriteLine() to get the code below...

fileStream->Position = 0;
for(int index = 0; index < 3; index++)
{
string = streamReader->ReadLine();
fileStream->Position = 0; // fileStream->Seek(0, SeekOrigin::Begin); behaves the same.
streamWriter->WriteLine(string + "X"); // Notice the appended X
}

And I get the ouput I want, but not what was expected (I expected one line in the file "[UVLO Test]X"). The output file now looks like this...

[Line Test]X
[OVP Test]X
[SCP Test]X
[UVLO Test]X

I don't understand why the file position is not being set the way I would expect it.

Thanks

Buck
GeneralRe: StreamReader, StreamWriter and File Position? Pin
Mark Salsbery16-Oct-07 9:26
Mark Salsbery16-Oct-07 9:26 
GeneralRe: StreamReader, StreamWriter and File Position? Pin
BuckBrown16-Oct-07 10:11
BuckBrown16-Oct-07 10:11 
GeneralRe: StreamReader, StreamWriter and File Position? Pin
Mark Salsbery16-Oct-07 10:29
Mark Salsbery16-Oct-07 10:29 
GeneralRe: StreamReader, StreamWriter and File Position? Pin
BuckBrown16-Oct-07 11:12
BuckBrown16-Oct-07 11:12 
GeneralRe: StreamReader, StreamWriter and File Position? Pin
Mark Salsbery16-Oct-07 11:27
Mark Salsbery16-Oct-07 11:27 
GeneralRe: StreamReader, StreamWriter and File Position? Pin
BuckBrown16-Oct-07 11:30
BuckBrown16-Oct-07 11:30 
GeneralRe: StreamReader, StreamWriter and File Position? Pin
Mark Salsbery16-Oct-07 11:51
Mark Salsbery16-Oct-07 11:51 
QuestionHow to get HWND from System::Windows::Forms::Panel^ panel [modified] Pin
Newbie0014-Oct-07 0:35
Newbie0014-Oct-07 0:35 
AnswerRe: How to get HWND from System::Windows::Forms::Panel^ panel Pin
Mark Salsbery14-Oct-07 5:53
Mark Salsbery14-Oct-07 5:53 
GeneralRe: How to get HWND from System::Windows::Forms::Panel^ panel Pin
Newbie0014-Oct-07 7:02
Newbie0014-Oct-07 7:02 
GeneralRe: How to get HWND from System::Windows::Forms::Panel^ panel Pin
Mark Salsbery14-Oct-07 7:19
Mark Salsbery14-Oct-07 7:19 
GeneralRe: How to get HWND from System::Windows::Forms::Panel^ panel Pin
Newbie0014-Oct-07 7:29
Newbie0014-Oct-07 7:29 
GeneralRe: How to get HWND from System::Windows::Forms::Panel^ panel Pin
Mark Salsbery14-Oct-07 8:00
Mark Salsbery14-Oct-07 8:00 
GeneralRe: How to get HWND from System::Windows::Forms::Panel^ panel Pin
Newbie0014-Oct-07 8:02
Newbie0014-Oct-07 8:02 
GeneralRe: How to get HWND from System::Windows::Forms::Panel^ panel Pin
Mark Salsbery14-Oct-07 8:22
Mark Salsbery14-Oct-07 8:22 
GeneralRe: How to get HWND from System::Windows::Forms::Panel^ panel Pin
Newbie0014-Oct-07 10:04
Newbie0014-Oct-07 10:04 
GeneralRe: How to get HWND from System::Windows::Forms::Panel^ panel Pin
Mark Salsbery14-Oct-07 10:24
Mark Salsbery14-Oct-07 10:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.