ArcEngine打开地图文件路径

/// <summary>
/// 打开文件路径
/// </summary>
/// <returns></returns>
private string[] OpenGDBFile()
{
    
    
    string[] GDBFile = new string[2];
    OpenFileDialog OpenShpFile = new OpenFileDialog();
    OpenShpFile.Title = "打开GDB文件";
    OpenShpFile.InitialDirectory = "E:";
    OpenShpFile.Filter = "GDB文件(*.GDB)|*.SPX";
    OpenShpFile.RestoreDirectory = true;
    if (OpenShpFile.ShowDialog() == DialogResult.OK)
    {
    
    
        string ShapPath = OpenShpFile.FileName;
        //利用"\\"将文件路径分成两部分
        int Position = ShapPath.LastIndexOf("\\");

        string FilePath = ShapPath.Substring(0, Position);
        string ShpName = ShapPath.Substring(Position + 1);
        GDBFile[0] = FilePath + '\\';

        GDBFile[1] = ShpName;

    }
    return GDBFile;
}
/// <summary>
/// 打开文件路径
/// </summary>
/// <returns></returns>
private string[] OpenShapeFile()
{
    
    
    string[] ShpFile = new string[2];
    OpenFileDialog OpenShpFile = new OpenFileDialog();
    OpenShpFile.Title = "打开Shape文件";
    OpenShpFile.InitialDirectory = "E:";
    OpenShpFile.Filter = "Shape文件(*.shp)|*.shp";
    OpenShpFile.RestoreDirectory = true;
    if (OpenShpFile.ShowDialog() == DialogResult.OK)
    {
    
    
        string ShapPath = OpenShpFile.FileName;
        //利用"\\"将文件路径分成两部分
        int Position = ShapPath.LastIndexOf("\\");

        string FilePath = ShapPath.Substring(0, Position);
        string ShpName = ShapPath.Substring(Position + 1);
        ShpFile[0] = FilePath + '\\';

        ShpFile[1] = ShpName;

    }
    return ShpFile;
}
   /// <summary>
    /// 保存文件路径
    /// </summary>
    /// <returns></returns>
    private string[] SaveAsShapeFile()
    {
    
    
        string[] ShpFile = new string[2];
        SaveFileDialog saveFileDialog = new SaveFileDialog();
        saveFileDialog.Title = "保存Shape文件";
        saveFileDialog.InitialDirectory = "E:";
        saveFileDialog.Filter = "shape files (*.shp)|*.shp|All files (*.*)|*.*";
        saveFileDialog.RestoreDirectory = true;
        if (saveFileDialog.ShowDialog() == DialogResult.OK)
        {
    
    
            string ShapPath = saveFileDialog.FileName;
            //利用"\\"将文件路径分成两部分
            int Position = ShapPath.LastIndexOf("\\");

            string FilePath = ShapPath.Substring(0, Position);
            string ShpName = ShapPath.Substring(Position + 1);
            ShpFile[0] = FilePath + '\\';

            ShpFile[1] = ShpName;

        }
        return ShpFile;
    }

猜你喜欢

转载自blog.csdn.net/firstlt0217/article/details/110135574