This document is archived and information here might be outdated.  Recommended version.


ISpatialReferenceFactory.CreateESRISpatialReferenceFromPRJFile Method (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > Geometry > ESRI.ArcGIS.Geometry > Interfaces > IS > ISpatialReferenceFactory Interface > ISpatialReferenceFactory.CreateESRISpatialReferenceFromPRJFile Method
ArcGIS Developer Help

ISpatialReferenceFactory.CreateESRISpatialReferenceFromPRJFile Method

Creates a spatial reference from a PRJ file.

[Visual Basic .NET]
Public Function CreateESRISpatialReferenceFromPRJFile ( _
    ByVal prjFile As String _
) As ISpatialReference
[C#]
public ISpatialReference CreateESRISpatialReferenceFromPRJFile (
    string prjFile
);
[C++]
HRESULT CreateESRISpatialReferenceFromPRJFile(
  BSTR prjFile
);
[C++]
Parameters
prjFile 

prjFile is a parameter of type BSTR

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Remarks

Both old style (workstation) and new style (ArcGIS for Desktop Basic) prj files can be used with this method to create spatial reference system objects.

[C#]

    public void CreateESRISpatialReferenceFromPRJFileExample()
    {
        //The ISpatialReferenceFactory::CreateESRISpatialReferenceFromPRJFile
        //method requires that you specify the path and filename of the PRJ
        //file you wish to import to create a spatial reference from.

        // use activator class with SpatialReferenceEnvironment singleton
        Type factoryType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
        System.Object obj = Activator.CreateInstance(factoryType);
        ISpatialReferenceFactory3 spatialReferenceFactory = obj as ISpatialReferenceFactory3;

        ISpatialReference spatialReference = spatialReferenceFactory.
            CreateESRISpatialReferenceFromPRJFile("C:\\Program Files\\ArcGIS\\Coordinate Systems\\Geographic Coordinate Systems\\World\\WGS 1984.prj");
    }

[Visual Basic .NET]

        'The ISpatialReferenceFactory::CreateESRISpatialReferenceFromPRJFile
        'method requires that you specify the path and filename of the PRJ
        'file you wish to import to create a spatial reference from.

        Dim pSpatRefFact As ESRI.ArcGIS.Geometry.ISpatialReferenceFactory
        pSpatRefFact = New ESRI.ArcGIS.Geometry.SpatialReferenceEnvironment

        Dim pSpatRef As ESRI.ArcGIS.Geometry.ISpatialReference
        pSpatRef = pSpatRefFact.CreateESRISpatialReferenceFromPRJFile("c:\geodata\prj_import.prj")

See Also

ISpatialReferenceFactory Interface

.NET Samples

StreetMap routing