public void CreateMdbfile(string strMdbFileName)
{
if (!File.Exists(strMdbFileName))
{
string mdbfileName = System.IO.Path.GetFileNameWithoutExtension(strMdbFileName); //test
string fileName = System.IO.Path.GetFileName(strMdbFileName);//返回文件名 test.mdb
string fileDirectory = System.IO.Path.GetDirectoryName(strMdbFileName);//返回文件目录 f://temp
if (mdbfileName == "") return;
IWorkspaceFactory workspaceFactory = new AccessWorkspaceFactoryClass();
IWorkspaceName workspaceName = workspaceFactory.Create(fileDirectory, mdbfileName, null, 0);
IName name = workspaceName as IName;
IWorkspace workspace = (IWorkspace)name.Open();
IFeatureWorkspace pFeWs = workspace as IFeatureWorkspace;
this.Close();
this.Dispose();
}
else
{
MessageBox.Show("文件夹下已存在该mdb文件,请先删除");
}
}