Hey guys,
I am using a simple try--catch in C#. When everything is well, the drive maps and moves on. When there is an error and it goes to catch, I get an infinite loop of MessageBox with the error and it seems to be looping the try.
TypeScript Copy
private void timer5_Tick (object sender, EventArgs e )
{
NetworkDrive oNetDrive1 = new NetworkDrive ();
zUpdateStatus ("Mapping ********... " );
try
{
oNetDrive1.LocalDrive = "w:" ;
oNetDrive1.ShareName = @"\\*******\**" ;
if (txtPassword.Text == "" && txtUsername.Text == "" )
{
oNetDrive1.MapDrive ();
}
else if (txtUsername.Text == "" )
{
oNetDrive1.MapDrive (txtPassword.Text );
}
else
{
oNetDrive1.MapDrive ("w2k\\" + txtUsername.Text , txtPassword.Text );
}
zUpdateStatus ("Drive map successful." );
}
catch (Exception err1)
{
zUpdateStatus ("Cannot map drive! - " + err1.Message );
MessageBox .Show (this , "Error (W). The systems administrator has been notified.\nError: " + err1.Message );
}
oNetDrive1 = null ;
}
Thanks...
Suthish NairRank #92 · 22.8K reputationPosted Nov 3, 2010, 9:24 AM EDT
try setting,
Alex Paluzzi3 reputationPosted Nov 3, 2010, 8:21 AM EDT