title: AutoCAD C# Release .dwl file
body: <p>Hello AutoCAD C# Masters,
  I have this code down here that opens a drawing, change some layers and close, but after it's done and the drawing closes, there is a file named <strong>DocName.dwl</strong> in the same folder as the dwg that I can't delete without closing autocad.</p>
  
  <p>Is there a place where I can release the lock and I'm not doing?</p>
  
  <pre><code>    [CommandMethod("Test", CommandFlags.UsePickSet | CommandFlags.Redraw | CommandFlags.Session | CommandFlags.Modal)]
      public void Test()
      {
          var DocList = AskUserToSelectDocs();
          foreach (string FileName in DocList.Files)
          {
              Application.DocumentManager.Open(FileName, false);
              Document zcDoc = Application.DocumentManager.MdiActiveDocument;
              Database zcDB = zcDoc.Database;
  
              using (DocumentLock acLckDoc = zcDoc.LockDocument())
              {
                  using (Transaction ZcTran = zcDoc.TransactionManager.StartTransaction())
                  {
                      BlockTable zcBLT = (BlockTable)ZcTran.GetObject(zcDB.BlockTableId, OpenMode.ForWrite);
                      BlockTableRecord zcBLTR = (BlockTableRecord)ZcTran.GetObject(zcBLT[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
  
                      zcBLTR.UpgradeOpen();
                      var editor = zcDoc.Editor;
  
                      var SelectionSet = editor.SelectAll().Value;
  
                      foreach (ObjectId Objeto in SelectionSet.GetObjectIds())
                      {
                          Entity ent = ZcTran.GetObject(Objeto, OpenMode.ForWrite) as Entity;
                          if (ent is Viewport)
                          {
                              var VP = ent as Viewport;
                              VP.Layer = "Defpoints";
                          }
                      }
  
                      editor.Regen();
  
                      ZcTran.Commit();
                  }
  
              }
  
              zcDB.SaveAs(zcDB.Filename, zcDB.OriginalFileVersion);
              zcDoc.CloseAndSave(zcDoc.Name);
              zcDoc.Dispose();
          }
      }
  </code></pre>
  
  <p><strong>EDIT: Now the full code</strong></p>
  
  <p>Thanks!</p>