打开表

2015-06-10 11:45:17  访问(1323) 赞(0) 踩(0)


		// returns true when a table was attempted to be opened, false when OpenFileDialog cancelled.
		private bool OpenTable(out Table table)
		{
			string filename = null;
			string s;
			OpenFileDialog openFile = new OpenFileDialog();
			openFile.DefaultExt = "tab";
			// The Filter property requires a search string after the pipe ( | )
			openFile.Filter = "MapInfo Tables (*.tab)|*.tab";
			openFile.Multiselect = false;
			table = null;
			if (openFile.ShowDialog() == DialogResult.OK) 
			{
				if( openFile.FileName.Length > 0 )
				{
					filename = openFile.FileName;
					//				MessageBox.Show(filename);
					if (Session.Current.TableSearchPath.FileExists(System.IO.Directory.GetCurrentDirectory(), filename, out s)) 
					{
						//					MessageBox.Show("file exists");
						table = Session.Current.Catalog.OpenTable(s);
					}
					else
					{
						// try anyway, at least we will get an exception to report
						table = Session.Current.Catalog.OpenTable(filename);
					}
					return true;
				}
			}
			return false;
		}


标签:打开表 

上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)