K
Ken
HI:
I'm running an application on either Win2K or Win98. It always works fine
on Win2K but on Win98 the String.IndexOf method always returns -1. Code is
found below. I cut out all the code that has no bearing on what is
happening so it might look a little weird. The offending line is in the
ExtractMessageFragment method.
Does anyone know why there is a difference. I'm running the 1.1 version of
the framework on both OS's and building the application on my Win2K machine
with Visual Studio 2003.
Thanks
Ken
private void LoadMessages ( )
{
String line;
line = "This is some text and some more text then we will find Last
Modified On: 07/18/2003";
this.ExtractMessageFragment ( ref line );
this.tbNews.Text = line;
} // end LoadMessages
private void ExtractMessageFragment ( ref String line )
{
DateTime CurrentDate = DateTime.Now;
DateTime MsgDate;
Int32 SavePos = 0,
DaysToView = 180;
Boolean Found = false;
do
{
// This line always returns -1 under Windows 98
SavePos = line.IndexOf ( "Last Modified On:", SavePos + 1 );
if ( SavePos == -1 )
{
line = "Message File Error";
break;
}
MsgDate = DateTime.Parse ( line.Substring ( SavePos + 18,
10 ) );
if ( CurrentDate.Subtract ( MsgDate ).Days <= DaysToView )
{
Found = true;
}
} while ( !Found );
if ( Found )
{
line = line.Substring ( SavePos - 19 );
}
} // end ExtractMessageFragment
I'm running an application on either Win2K or Win98. It always works fine
on Win2K but on Win98 the String.IndexOf method always returns -1. Code is
found below. I cut out all the code that has no bearing on what is
happening so it might look a little weird. The offending line is in the
ExtractMessageFragment method.
Does anyone know why there is a difference. I'm running the 1.1 version of
the framework on both OS's and building the application on my Win2K machine
with Visual Studio 2003.
Thanks
Ken
private void LoadMessages ( )
{
String line;
line = "This is some text and some more text then we will find Last
Modified On: 07/18/2003";
this.ExtractMessageFragment ( ref line );
this.tbNews.Text = line;
} // end LoadMessages
private void ExtractMessageFragment ( ref String line )
{
DateTime CurrentDate = DateTime.Now;
DateTime MsgDate;
Int32 SavePos = 0,
DaysToView = 180;
Boolean Found = false;
do
{
// This line always returns -1 under Windows 98
SavePos = line.IndexOf ( "Last Modified On:", SavePos + 1 );
if ( SavePos == -1 )
{
line = "Message File Error";
break;
}
MsgDate = DateTime.Parse ( line.Substring ( SavePos + 18,
10 ) );
if ( CurrentDate.Subtract ( MsgDate ).Days <= DaysToView )
{
Found = true;
}
} while ( !Found );
if ( Found )
{
line = line.Substring ( SavePos - 19 );
}
} // end ExtractMessageFragment