I have the following code snippet in C# to open a PowerDesigner Model and I would like to close / exit the PowerDesigner application instance but I do not know how?
PdCommon.Application pdApplication = null;
try{
//Creating PD Application object...
pdApplication = new PdCommon.Application();
//Opening the relevant models of a dedicated directory
String[] files = System.IO.Directory.GetFiles(ldmSourceDirectory);
foreach (String curFile in files){
if(curFile.EndsWith(".cdm")){
pdApplication.OpenModel(@curFile, PdCommon.OpenModelFlags.omf_DontOpenView);
}
}
//Doing some operations...
}finally{
if (pdApplication != null){
//Closing models
foreach (PdCDM.Model curPDModel in pdApplication.Models){
curPDModel.Close(false);
}
//But how can I close the application?
pdApplication = null;
}
}
As commented by pascal, you should close the model, the workspace, and then, kill the process. DonĀ“t forget to add PdWSP (workspace model) reference, and System.Diagnostics using declaration. The process name may be different depending on the PD version.