RCP软件退出时,清空工作空间内容

it2024-11-10  13

 重载ApplicationWorkbenchWindowAdvisor中的postWindowClose() 方法

@Override public void postWindowClose() {  // TODO Auto-generated method stub  //super.postWindowClose();  boolean openConfirm = MessageDialog.openConfirm(null, Messages.ApplicationWorkbenchWindowAdvisor_title, Messages.ApplicationWorkbenchWindowAdvisor_content);  if(openConfirm)  {   Location instanceLocation = Platform.getInstanceLocation();   URL path = instanceLocation.getURL();   //关闭数据库连接   SQLiteDBHelper.getSQLiteInstace().Close();   File  workspace= new File(path.getPath());//+File.separator+SQLiteDBHelper.DB_FILE_NAME   //删除程序运行的临时记录   deleteFile(workspace);  }   } //删除文件夹及文件夹内容 public void deleteFile(File targetFile) {  if(targetFile.isDirectory())  {   File[] list = targetFile.listFiles();   for (int i = 0; i < list.length; i++) {    deleteFile(list[i]);   }   //   targetFile.deleteOnExit();  }  else   targetFile.deleteOnExit(); }   

转载于:https://www.cnblogs.com/wuhenke/archive/2012/03/07/2384201.html

最新回复(0)