Datasource access and modification of layers in ArcGIS Engine

Source: Internet
Author: User

Datasource access and modification of layers in ArcGIS Engine 09-11-19 09:29:09 http://blog.csdn.net/rrrrssss00


Core Tip: datasource access and modification of layers in ArcGIS Engine

When a layer can be accessed normally, you can obtain the data source path of the layer as follows:

Ifeature pfeaturelayer = (ifeaturelayer) player;
Ifeature fc = (ifeatureclass) pfeaturelayer. featureclass;
FDS = (ifeaturedataset) FC. featuredataset;
Ws = (iworkspace) FDS. workspace;
String S = ws. pathname. toupper ();

When the layer cannot be accessed normally and the data source needs to be repaired, the ifeatureclass obtained in the above method is empty. In this case, you can obtain the data source path of the layer in the following way:
Idatalayer pdlayer = (idatalayer) player;
Iworkspacename Ws = (idatasetname) (pdlayer. javascename). workspacename;
This. textbox2.text = ws. pathname;

Data Source modification method

1. filegdb
Idatalayer2 pdlayer = (idatalayer2) pflayer;
Idatasetname pdsname = (idatasetname) (pdlayer. CENAME );
Iworkspacename Ws = pdsname. workspacename;
This. textbox2.text = ws. pathname;
String newpath = @ "J:/work/windowsapplication1/windowsapplication1/bin/New. GDB ";
WS. workspacefactoryprogid = "esrisponcesgdb. filegdbworkspacefactory ";
WS. pathname = newpath;
Pdsname. workspacename = ws;
Pmapdocument. Save (True, true );

2. SHP File
Idatalayer2 pdlayer = (idatalayer2) pflayer;
Idatasetname pdsname = (idatasetname) (pdlayer. CENAME );
Iworkspacename Ws = pdsname. workspacename;
This. textbox2.text = ws. pathname;
String newpath = @ "J:/work/windowsapplication1/windowsapplication1/bin /";
WS. pathname = newpath;
Pdsname. workspacename = ws;
Pmapdocument. Save (True, true );

This article Article from GIS Power Station | www.gispower.org Original article: http://www.gispower.org/article/arcgis/ao/2009/1119/0911199299K0H733CH3E627648888G.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.