Hello Everyone,
this is Tauhid from Bangladesh. I am a beginner in ArcGIS development with C#. Now i Am trying to create a featuredataset using ISpatialReferenceDialogBox in a fileGDB. but I am stuck with the code. Of my form the groupbox named as Frame1 which is contain the cmdDataSet button . the code is given Below:
private void cmdDataSet_Click(object sender, EventArgs e)
{
string strdatabasePath = "C:\\" + @txtProject.Text + "\\Survey\\Data_Table\\" + @txtDatabase.Text + @txtSub.Text;
if (!Directory.Exists(strdatabasePath) == false)
{
MessageBox.Show("Destination Directory was not Found, Please Create the Directory First");
}
IWorkspaceFactory pWSF = new FileGDBWorkspaceFactoryClass();
Boolean blsWorkspace = pWSF.IsWorkspace("C:\\" + @txtProject.Text + "\\Survey\\GeoDatabase\\" + @txtDatabase.Text + "\\" + @txtDatabase.Text +".gdb");
if (blsWorkspace == true)
{
IWorkspace pWorkspace = pWSF.OpenFromFile("C:\\" + @txtProject.Text + "\\Survey\\GeoDatabase\\" + @txtDatabase.Text + "\\" + @txtDatabase.Text + ".gdb", 0);
IFeatureWorkspace pfeatureWorkspace = (IFeatureWorkspace)pWorkspace;
IEnumDatasetName pEnumDatasetName = pWorkspace.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
IDatasetName pDatasetName = pEnumDatasetName.Next();
string theDatasetName;
int theValue;
while (pDatasetName == null)
{
theDatasetName = pDatasetName.Name;
if (theDatasetName == txtSub.Text)
{
theValue = 1;
}
pDatasetName = pEnumDatasetName.Next();
}
if (theValue == null)
{
ISpatialReferenceDialog pSpaRef = new SpatialReferenceDialogClass();
ISpatialReference m_SpaRef1 = pSpaRef.DoModalCreate(true, true, true, Frame1.ActiveControl);
IFeatureDataset pfeatDataset;
while m_SpaRef1 == false
{
pfeatDataset = pfeatureWorkspace.CreateFeatureDataset(txtSub.Text, m_SpaRef1);
MessageBox.Show("FeatureDataset Created");
}
MessageBox.Show("No Spatial Reference Found, Feature Dataset was Not Created");
}
}
}
But its not working. It shows error in "ISpatialReference m_SpaRef1 = pSpaRef.DoModalCreate(true, true, true, Frame1.ActiveControl);" this part of code. Can Anyone please give me the solution? I tried to find the solution but can't fix it.
Tauhid
GIS Specialist
NERCA International Ltd