Adding handler for 'Open Table' button in MapXtreme Desktop Application

Products Affected: MapXtreme.NET
C# Code:
private void mapToolBar1_ButtonClick(object sender, ToolBarButtonClickEventArgs e)
{
//check to see if its the customOpenTable button
if((string)e.Button.Tag == (string)"customOpenTable")
{
//create a new OpenTableDialog object
System.Windows.Forms.OpenFileDialog openTableDlg = 
new OpenFileDialog();
//set the properties to look for MapInfo related files
openTableDlg.InitialDirectory = "c:\\" ;
openTableDlg.Filter = ".mws files (*.mws)|*.mws|.tab files (*.tab)|*.tab|All Files (*.*)|*.*";
openTableDlg.FilterIndex = 1 ;
openTableDlg.RestoreDirectory = true ;
//After the user clicks OK...
if(openTableDlg.ShowDialog() == DialogResult.OK)
{
//check to see what type of file was selected, and process
//Open Connection 
MapInfo.Data.MIConnection conn = new MapInfo.Data.MIConnection();
conn.Open();

//Create fileInfo object to hold file path information
System.IO.FileInfo fileInfo = new System.IO.FileInfo(openTableDlg.FileName);

//check table extensions and open tables
if (fileInfo.Extension.ToUpper() == ".TAB")
{
MapInfo.Mapping.MapTableLoader loader = 
new MapTableLoader(openTableDlg.FileName);
this.mapControl1.Map.Load(loader);
}
else if (fileInfo.Extension.ToUpper() == ".MWS")
{
MapInfo.Mapping.MapWorkSpaceLoader wloader =
new MapWorkSpaceLoader(openTableDlg.FileName);
this.mapControl1.Map.Load(wloader);
}
}
}
}
UPDATED:  September 13, 2019