本文整理汇总了C#中Geoprocessor.ListTables方法的典型用法代码示例。如果您正苦于以下问题:C# Geoprocessor.ListTables方法的具体用法?C# Geoprocessor.ListTables怎么用?C# Geoprocessor.ListTables使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Geoprocessor
的用法示例。
在下文中一共展示了Geoprocessor.ListTables方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertPersonalGeodatabaseToFileGeodatabase
private static void ConvertPersonalGeodatabaseToFileGeodatabase()
{
// Initialize the Geoprocessor
Geoprocessor geoprocessor = new Geoprocessor();
// Allow for the overwriting of file geodatabases, if they previously exist.
geoprocessor.OverwriteOutput = true;
// Set the workspace to a folder containing personal geodatabases.
geoprocessor.SetEnvironmentValue("workspace", @"C:\data");
// Identify personal geodatabases.
IGpEnumList workspaces = geoprocessor.ListWorkspaces("*", "Access");
string workspace = workspaces.Next();
while (workspace != "")
{
// Set workspace to current personal geodatabase
geoprocessor.SetEnvironmentValue("workspace", workspace);
// Create a file geodatabase with the same name as the personal geodatabase
string gdbname = System.IO.Path.GetFileName(workspace).Replace(".mdb", "");
string dirname = System.IO.Path.GetDirectoryName(workspace);
// Execute CreateFileGDB tool
CreateFileGDB createFileGDBTool = new CreateFileGDB(dirname, gdbname + ".gdb");
geoprocessor.Execute(createFileGDBTool, null);
// Initialize the Copy Tool
Copy copyTool = new Copy();
// Identify feature classes and copy to file geodatabase
IGpEnumList fcs = geoprocessor.ListFeatureClasses("", "", "");
string fc = fcs.Next();
while (fc != "")
{
Console.WriteLine("Copying " + fc + " to " + gdbname + ".gdb");
copyTool.in_data = fc;
copyTool.out_data = dirname + "\\" + gdbname + ".gdb" + "\\" + fc;
geoprocessor.Execute(copyTool, null);
fc = fcs.Next();
}
// Identify feature datasets and copy to file geodatabase
IGpEnumList fds = geoprocessor.ListDatasets("", "");
string fd = fds.Next();
while (fd != "")
{
Console.WriteLine("Copying " + fd + " to " + gdbname + ".gdb");
copyTool.in_data = fd;
copyTool.data_type = "FeatureDataset";
copyTool.out_data = dirname + "\\" + gdbname + ".gdb" + "\\" + fd;
try
{
geoprocessor.Execute(copyTool, null);
}
catch (Exception ex)
{
object sev = null;
System.Windows.Forms.MessageBox.Show(ex.Message);
}
fd = fds.Next();
}
// Identify tables and copy to file geodatabase
IGpEnumList tbls = geoprocessor.ListTables("", "");
string tbl = tbls.Next();
while (tbl != "")
{
Console.WriteLine("Copying " + tbl + " to " + gdbname + ".gdb");
copyTool.in_data = tbl;
copyTool.out_data = dirname + "\\" + gdbname + ".gdb" + "\\" + tbl;
geoprocessor.Execute(copyTool, null);
tbl = tbls.Next();
}
workspace = workspaces.Next();
}
}