02-19-2018 03:16 AM - edited 02-21-2018 01:35 AM
I need to copy a style subfolder called "New Folder" from a library connection to a gws,
I already made the connection to the library using the below code:
PLSS.LibraryConnection libraryConnection =this._currentApplication.CreateService("GeoMedia.LibraryConnection") as PLSS.LibraryConnection; libraryConnection.Name = "Access Library Connection 1"; libraryConnection.Description = "Library"; libraryConnection.Mode = 1; libraryConnection.ConnectionString = @"TYPE=GDO;PROGID=ACCESS.GDatabase;LOCATION=C:\Users\A\Desktop\Edited\try\LibTemp.mdb"; libraryConnection.Connect(true, null); PLSS.LibraryConnections libConns = this._document.LibraryConnections as PLSS.LibraryConnections; libConns.Append(libraryConnection);
And I copied the content of the library as follows:
PLSS.Library objLibrary = libraryConnection.Library;
PLSS.LibraryStorageService libStorSrvc = this._currentApplication.CreateService("GeoMedia.LibraryStorageService") as PLSS.LibraryStorageService;
libStorSrvc.LibraryConnection = libraryConnection;
libStorSrvc.CopyMode = 1;
libStorSrvc.TargetConnections = this._document.Connections;
libStorSrvc.TargetCoordSystemsMgr = this._document.CoordSystemsMgr;
libStorSrvc.TargetQueryFolder = this._document.QueryFolder;
PLSS.LibraryFolder libfold = objLibrary.StyleFolder;
PLSS.LibraryFolder libfoldinner = libfold.LibrarySubFolders; //New Folder
object objCreatedCopy = libStorSrvc.CopyFromLibrary(libfoldinner.LibrarySubFolders.Moniker, true);
PView.StyleFolder docStyleFolder = this._document.StyleFolder as PView.StyleFolder;
PView.StyleFolder docStyleFolderinner = objCreatedCopy as PView.StyleFolder;
This Post is edited as I found a way to do it and the above code now works,
Solved! Go to Solution.
02-21-2018 01:28 AM
I finally got it right:
The Style folder is saved as a library folder under the Library, so I firstly made a library folder "libfold" respresenting the library style folder.
In order to control my style subfolder named "New Folder" under the library stylefolder I had to make another library folder "libfoldinner" representing the LibrarySubFolders which in my case respresent the "New Folder" style subfolder.
Then I created a copy of this "New Folder" using "CopyFromLibrary" method.
In order to receive that copy in the gws style folder I made the following:
Created a stylefolder "docStyleFolder" representing the document stylefolder,
Created another stylefolder called "docStyleFolderinner" and I set it to the object returned from the "CopyFromLibrary" method.
Then I appended the "docStyleFolderinner" as a stylesubfolder into the "docStyleFolder"
I edited the code above.
I hope this answer could benefit you.