This is a C# routine that I use to open all of the files in a folder.
Code:
// Application Session Command with localized name
[CommandMethod("CommandGroup", "CommandName", "LocalCommandName", CommandFlags.Modal | CommandFlags.Session)]
public void ExportDWG()
{
string strPath = "";
strPath = BrowseFolder(); //Routine that shows dialog and returns path to a folder
// Process the list of files found in the directory.
string[] fileEntries = Directory.GetFiles(strPath, "*.dwg");
foreach (string strFileName in fileEntries)
{
//Only Process Files that end with .DWG
if (strFileName.EndsWith(".DWG", StringComparison.OrdinalIgnoreCase))
{
Database acadDB = new Database();
//Open Drawing File
acadDB.ReadDwgFile(strFileName, FileShare.ReadWrite, true, "");
Transaction acadtrans = acadDB.TransactionManager.StartTransaction();
try
{
// Place Code Here
acadtrans.Commit();
}
catch (Autodesk.AutoCAD.Runtime.Exception)
{
acadtrans.Abort();
}
finally
{
acadtrans.Dispose();
acadDB.Dispose();
}
}
}
}