ArcObjects Library Reference

Create Datum List Textfile Snippet

Writes the list of coordinate tool datums and ellipsoids to a user specified text file.

[C#]

///<summary>Writes the list of coordinate tool datums and ellipsoids to a user specified text file.</summary>
/// 
///<param name="datumPathFile">A System.String that is path and filename where the listing of datums is created. Example: "c:\temp\mydatums.txt"</param>
///  
///<remarks></remarks>
public void CreateDatumListTextfile(System.String datumPathFile)
{
  // Initialize the Coordinate tool.
  ESRI.ArcGIS.DefenseSolutions.ICoordinateTool coordinateTool = new ESRI.ArcGIS.DefenseSolutions.CoordinateToolClass();

  // Generate the list of datums as a string array.
  string[] s = coordinateTool.GetDatumList();

  // Create a text file.
  System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(datumPathFile);

  // Add the datum and ellipsoid strings to it.
  for (System.Int32 i = 0; i <= s.Length; i++)
  // for (int i = LBound(s); i <= UBound(s); i++)
  {
      streamWriter.WriteLine("Datum: " + System.Convert.ToString(i) + " : " + s[i] + System.Environment.NewLine + "Ellipsoid: " + coordinateTool.GetDatumEllipsoid(i));
  }

  // Close the file.
  streamWriter.Close();
}
[Visual Basic .NET]

'''<summary>Writes the list of coordinate tool datums and ellipsoids to a user specified text file.</summary>
''' 
'''<param name="datumPathFile">A System.String that is path and filename where the listing of datums is created. Example: "c:\temp\mydatums.txt"</param>
'''  
'''<remarks></remarks>
Public Sub CreateDatumListTextfile(ByVal datumPathFile As System.String)

  'Initialize the Coordinate tool.
  Dim coordinateTool As ESRI.ArcGIS.DefenseSolutions.ICoordinateTool = New ESRI.ArcGIS.DefenseSolutions.CoordinateToolClass

  'Generate the list of datums as a string array.
  Dim s() As System.String = coordinateTool.GetDatumList

  'Create a text file
  Dim streamWriter As System.IO.StreamWriter = New System.IO.StreamWriter(datumPathFile)

  Dim i As System.Int32
  'Add the datum and ellipsoid strings to it.
    For i = 0 To s.Length - 1
      streamWriter.WriteLine("Datum: " + System.Convert.ToString(i) + " : " + s(i) + System.Environment.NewLine + "Ellipsoid: " + coordinateTool.GetDatumEllipsoid(i))
    Next i

  'Close the file.
  streamWriter.Close()

End Sub


Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.DefenseSolutions
  • ESRI.ArcGIS.Geometry
  • System