Thank you friends I used the following code :
public void IWorkspaceFactory_Create_Example_Access()
{
path = saveFDBExport.FileName;
outputfilePath = saveFDBExport.FileName;
i = outputfilePath.LastIndexOf("\\");
outpufilename = outputfilePath.Substring(i + 1);
outputfilePath = outputfilePath.Substring(0, i);
// create a new Access workspace factory
IWorkspaceFactory workspaceFactory = new AccessWorkspaceFactoryClass();
// Create a workspacename with the workspace factory
IWorkspaceName workspaceName = workspaceFactory.Create(outputfilePath, outpufilename, null, 0);
// Cast for IName
ESRI.ArcGIS.esriSystem.IName name = (ESRI.ArcGIS.esriSystem.IName)workspaceName;
//Open a reference to the access workspace through the name object
IWorkspace pGDB_workspace = (IWorkspace)name.Open();
//Getting the Transfer
GetTransfer();
}
public void GetTransfer()
{
try
{
m_pMxdocument = m_application.Document as IMxDocument;
////Get the first layer in the map
pMap = m_pMxdocument.FocusMap;
IFeatureLayer featureLayer = pMap.get_Layer(0) as IFeatureLayer;
IFeatureClass inputFeatureClass = featureLayer.FeatureClass;
IDataset inputDataset = (IDataset)inputFeatureClass;
IDatasetName inputDatasetName = (IDatasetName)inputDataset.FullName;
// If the user wan to Send the selected records
// Get the layer's selection set.
IFeatureSelection featureSelection = (IFeatureSelection)featureLayer;
ISelectionSet selectionSet = featureSelection.SelectionSet;
// Create a feature class name for the shapefile. This also requires creating a
// workspace name object - since we need a workspace instance to use the field checker,
// we might as well open it here.
IWorkspaceFactory AccessWKSpaceFactory = new AccessWorkspaceFactoryClass();
IWorkspace AccessWorkspace = AccessWKSpaceFactory.OpenFromFile(path, 0);
IDataset AccessWorkspaceDataset = (IDataset)AccessWorkspace;
IWorkspaceName workspaceName = (IWorkspaceName)AccessWorkspaceDataset.FullName;
IFeatureClassName AccessFeatureClassName = new FeatureClassNameClass();
IDatasetName AccessDatasetName = (IDatasetName)AccessFeatureClassName;
AccessDatasetName.WorkspaceName = workspaceName;
AccessDatasetName.Name = "accdt";
// Use the IFieldChecker interface to make sure all of the field names are valid for a shapefile.
IFieldChecker fieldChecker = new FieldCheckerClass();
IFields shapefileFields = null;
IEnumFieldError enumFieldError = null;
fieldChecker.InputWorkspace = inputDataset.Workspace;
fieldChecker.ValidateWorkspace = AccessWorkspace;
fieldChecker.Validate(inputFeatureClass.Fields, out enumFieldError, out shapefileFields);
// We also need to retrieve the GeometryDef from the input feature class.
int shapeFieldPosition = inputFeatureClass.FindField(inputFeatureClass.ShapeFieldName);
IFields inputFields = inputFeatureClass.Fields;
IField shapeField = inputFields.get_Field(shapeFieldPosition);
IGeometryDef geometryDef = shapeField.GeometryDef;
// Now we can create a feature data converter.
IFeatureDataConverter2 featureDataConverter2 = new FeatureDataConverterClass();
IEnumInvalidObject enumInvalidObject = featureDataConverter2.ConvertFeatureClass(inputDatasetName, null, selectionSet, null, AccessFeatureClassName, geometryDef, shapefileFields, "", 1000, 0);
// Again, checking for invalid objects would be useful at this point...
}
catch (Exception ex)
{
MessageBox.Show("" + ex);
}
}