Access and modification of layer paths in arcengine
(11:18:48)
Reprinted
| Tags: Modify the arcengine path to access it |
Category:Development |
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 );