title: How to open a .DWG file in Autocad 2014 through C#
body: <p>Hi I have a requirement in which I have to open a drawing file stored in C:\Temp Folder.
  I tried the following code</p>
  
  <pre><code>public void launchacad(string pth)  //pth is the path to the .DWG file
          {
              const string progID = "AutoCAD.Application.19.1";                
  
              const string exePath = @"C:\Program Files\Autodesk\AutoCAD 2014\acad.exe";
  
              AcadApplication acApp = null;
  
              try
              {
                  acApp =
                    (AcadApplication)Marshal.GetActiveObject(progID);
              }
              catch { }
  
              if (acApp != null)
              {
                  MessageBox.Show("An instance of AutoCAD is already running.");
              }
              else
              {
                  try
                  {                            
                      ProcessStartInfo psi =new ProcessStartInfo(exePath);
                      psi.WorkingDirectory = @"C:\Temp";
                      psi.Arguments = pth;
                      Process pr = Process.Start(psi);
  
                      pr.WaitForInputIdle();                            
  
                      while (acApp == null)
                      {
                          try
                          {
                              acApp =(AcadApplication)Marshal.GetActiveObject(progID);                            
                          }
                          catch
                          {                                    
                              Application.DoEvents();
                          }
                      }
                  }
                  catch (Exception ex)
                  {
                      MessageBox.Show(
                        "Cannot create or attach to AutoCAD object: "
                        + ex.Message
                      );
                  }
              }
  
              if (acApp != null)
              {
                  acApp.Visible = true;
                  acApp.ActiveDocument.SendCommand("_MYCOMMAND ");
              }
          }
  </code></pre>
  
  <p>But as soon as Autocad starts it popups an error message saying <code>Cannot find the specified drawing.</code> When I use CMD.exe and type</p>
  
  <pre><code>"C:\Program Files\Autodesk\AutoCAD 2014\acad.exe" "C:\Temp\41 Stabd.dwg"  It opens Autocad with the file(41 Stand.dwg) open.
  </code></pre>
  
  <p>I can't understand where I am making an error. Can someone help me out.</p>