public IFeatureClass CreateFCOutput(string outputPath, SaveAsType saveAsType, List<Graphic> graphicsList, ISpatialReference ipSpatialRef)
{
string fcName = System.IO.Path.GetFileName(outputPath);
string folderName = System.IO.Path.GetDirectoryName(outputPath);
IFeatureClass fc = null;
try
{
if (saveAsType == SaveAsType.FileGDB)
{
IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactory();
IWorkspace workspace = workspaceFactory.OpenFromFile(folderName, 0);
IFeatureWorkspace fWorkspace = (IFeatureWorkspace)workspace;
if (DoesFeatureClassExist(folderName, fcName))
{
DeleteFeatureClass(fWorkspace, fcName);
}
fc = CreatePolylineFeatureClass(fWorkspace, fcName);
foreach (Graphic graphic in graphicsList)
{
IFeature feature = fc.CreateFeature();
feature.Shape = graphic.Geometry;
feature.Store();
}
}
else if (saveAsType == SaveAsType.Shapefile)
{
// already asked them for confirmation to overwrite file
if (File.Exists(outputPath))
{
DeleteShapeFile(outputPath);
}
fc = ExportToShapefile(outputPath, graphicsList, ipSpatialRef);
}
return fc;
}
catch (Exception ex)
{
return fc;
}
}