+ Reply to Thread
Results 1 to 3 of 3

Thread: How to unlock shape file, just created

  1. #1
    Anatolii Terentiev
    Join Date
    Sep 2010
    Posts
    225
    Points
    2
    Answers Provided
    0


    0

    Default How to unlock shape file, just created

    I create shape file as follows:
    Code:
    IFeatureClass featClass = featWorkspace.CreateFeatureClass(shpName, fields, null, null, esriFeatureType.esriFTSimple, "Shape", "");
    And created shape file - is locked:
    file_name.shp.comp_name.3840.3932.sr.lock
    .
    How I can unlock shape file just created?

  2. #2
    Anatolii Terentiev
    Join Date
    Sep 2010
    Posts
    225
    Points
    2
    Answers Provided
    0


    0

    Default Re: How to unlock shape file, just created

    How I can remove Schema lock?
    That is full cod of creating shape file (C# VS2010 arcgis engine 2010):
    Code:
            public void createShpFile(string shpName, DataTable dataTable)                          
            {
                //++++++++++++++  Create a new Shapefile with given name +++++++++++++++++++++++++++
                //Get the factory
                ShapefileWorkspaceFactory factory = new ShapefileWorkspaceFactory();
    
                //Create a workspace
                IWorkspaceName workspaceName = factory.Create(parentDirectory, catalogName, null, 0);
                
    
                IName name = workspaceName as IName;
    
                //QI to IFeatureWorkspace
                IFeatureWorkspace featWorkspace = (IFeatureWorkspace)name.Open();
    
                // Create a Fields collection to describe the fields of the new feature class.
                IFields fields = new Fields();
                IFieldsEdit fieldsEdit = fields as IFieldsEdit;
    
                // Add an "OBJECTID" field (feature classes must have this!)
                IField oidField = new Field();
                IFieldEdit oidFieldEdit = oidField as IFieldEdit;
                oidFieldEdit.Name_2 = "OBJECTID";
                oidFieldEdit.Type_2 = esriFieldType.esriFieldTypeOID;
                fieldsEdit.AddField(oidField);
    
                // Create a geometry definition object describing the geometries
    
    
                ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironmentClass();
    
                IGeographicCoordinateSystem gcs = srFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);
                IProjectedCoordinateSystem pcs = srFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_Pulkovo1942GK_6);
                IGeometryDef geometryDef = new GeometryDef();
                IGeometryDefEdit geomDefEdit = geometryDef as IGeometryDefEdit;
                geomDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;
                geomDefEdit.SpatialReference_2 = pcs;
    
                IField shpField = new Field();
                IFieldEdit shpFieldEdit = shpField as IFieldEdit;
                shpFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
                shpFieldEdit.Name_2 = "Shape";
                shpFieldEdit.GeometryDef_2 = geomDefEdit;
                fieldsEdit.AddField(shpField);
    
                esriFieldType fieldType;
                int fieldLength;
                int i = 0;
    
                foreach (DataColumn col in dataTable.Columns)
                {
                    IField aField = new Field();
                    IFieldEdit aFieldEdit = aField as IFieldEdit;
                    getFieldType(col, out fieldType, out fieldLength);
                    aFieldEdit.Type_2 = fieldType;//esriFieldType.esriFieldTypeString
                    string colName = col.ColumnName;
                    if (colName.ToLower() == "площадь_нелесной_зоны")
                        colName = "ПлощадьНелеснойЗоны";
                    else if (colName == "код_пожара_сзбаол")
                        continue;// colName = "кодПожаразбаол";
                    else if (colName == "код_района_сзбаол")
                        continue;//
    
                    aFieldEdit.Name_2 = colName;
                    aFieldEdit.Length_2 = fieldLength;
                    fieldsEdit.AddField(aField);
                    i++;
                }
                //Create FeatureClass
                IFeatureClass featClass = featWorkspace.CreateFeatureClass(shpName, fields, null, null, esriFeatureType.esriFTSimple, "Shape", "");
               
    
            }

  3. #3
    Thavitinaidu Gulivindala
    Join Date
    May 2010
    Posts
    69
    Points
    22
    Answers Provided
    3


    0

    Default Re: How to unlock shape file, just created

    Quote Originally Posted by aviabunin View Post
    How I can remove Schema lock?
    That is full cod of creating shape file (C# VS2010 arcgis engine 2010):
    Code:
            public void createShpFile(string shpName, DataTable dataTable)                          
            {
                //++++++++++++++  Create a new Shapefile with given name +++++++++++++++++++++++++++
                //Get the factory
                ShapefileWorkspaceFactory factory = new ShapefileWorkspaceFactory();
    
                //Create a workspace
                IWorkspaceName workspaceName = factory.Create(parentDirectory, catalogName, null, 0);
                
    
                IName name = workspaceName as IName;
    
                //QI to IFeatureWorkspace
                IFeatureWorkspace featWorkspace = (IFeatureWorkspace)name.Open();
    
                // Create a Fields collection to describe the fields of the new feature class.
                IFields fields = new Fields();
                IFieldsEdit fieldsEdit = fields as IFieldsEdit;
    
                // Add an "OBJECTID" field (feature classes must have this!)
                IField oidField = new Field();
                IFieldEdit oidFieldEdit = oidField as IFieldEdit;
                oidFieldEdit.Name_2 = "OBJECTID";
                oidFieldEdit.Type_2 = esriFieldType.esriFieldTypeOID;
                fieldsEdit.AddField(oidField);
    
                // Create a geometry definition object describing the geometries
    
    
                ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironmentClass();
    
                IGeographicCoordinateSystem gcs = srFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);
                IProjectedCoordinateSystem pcs = srFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_Pulkovo1942GK_6);
                IGeometryDef geometryDef = new GeometryDef();
                IGeometryDefEdit geomDefEdit = geometryDef as IGeometryDefEdit;
                geomDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;
                geomDefEdit.SpatialReference_2 = pcs;
    
                IField shpField = new Field();
                IFieldEdit shpFieldEdit = shpField as IFieldEdit;
                shpFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
                shpFieldEdit.Name_2 = "Shape";
                shpFieldEdit.GeometryDef_2 = geomDefEdit;
                fieldsEdit.AddField(shpField);
    
                esriFieldType fieldType;
                int fieldLength;
                int i = 0;
    
                foreach (DataColumn col in dataTable.Columns)
                {
                    IField aField = new Field();
                    IFieldEdit aFieldEdit = aField as IFieldEdit;
                    getFieldType(col, out fieldType, out fieldLength);
                    aFieldEdit.Type_2 = fieldType;//esriFieldType.esriFieldTypeString
                    string colName = col.ColumnName;
                    if (colName.ToLower() == "площадь_нелесной_зоны")
                        colName = "ПлощадьНелеснойЗоны";
                    else if (colName == "код_пожара_сзбаол")
                        continue;// colName = "кодПожаразбаол";
                    else if (colName == "код_района_сзбаол")
                        continue;//
    
                    aFieldEdit.Name_2 = colName;
                    aFieldEdit.Length_2 = fieldLength;
                    fieldsEdit.AddField(aField);
                    i++;
                }
                //Create FeatureClass
                IFeatureClass featClass = featWorkspace.CreateFeatureClass(shpName, fields, null, null, esriFeatureType.esriFTSimple, "Shape", "");
               
    
            }

    Release the resources....IFeatureClass, IFeatureWorkspace variables....
    e.g. marshal.ReleaseComobject(featClass);
    Cheers,
    Thaviti

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts