Hello,
I am having problems using the Insert method of the ArrayList class. Can someone please tell me if there's something obviously wrong with the way that I am trying to insert a value into an arraylist? The following code compiles, but when I run the AutoCAD command, AutoCAD halts on the "bolded" line.
public class Commands
{
[CommandMethodAttribute("MxTest")]
public void MxUtilsTest()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
// Prompt user to select files.
ArrayList assemblyData = mmm.Mx.Utils.SelectFiles();
assemblyData.Insert(0, "PICS ACAD Assembly|12-3000-0450-9|A");
// Display user selected files.
foreach (Object item in assemblyData)
{
ed.WriteMessage("Assembly Data: {0}\n", item);
}
}
}
As a frame of reference, I have included the SelectFiles method that's called by the above method.
public static class Utils
{
/// <summary>
/// Prompts the user to select one or more drawing files.
/// </summary>
/// <returns>
/// An ArrayList containing one or more drawing files.
/// </returns>
public static ArrayList SelectFiles()
{
// Create an instance of the OpenFileDialog class.
Autodesk.AutoCAD.Windows.OpenFileDialog ofd =
new Autodesk.AutoCAD.Windows.OpenFileDialog
("Select One or More Drawing Files", null, "dwg", "MultipleDWGS",
Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags.AllowMultiple);
// Show common dialog box and determine if DialogResult = OK.
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string[] fileList = ofd.GetFilenames();
return ArrayList.Adapter(fileList);
}
else
{
return new ArrayList();
}
}
Thanks,
Nick