Can you provide more information on the filesNames variable?
Just that you have fileNames.Count and then fileNames.ToString()
Assuming this is an array or collection since is has a count property do you need to use filesNames(i).ToString(); in the loop?
Just be curious.
This is C# code, right?
In Lisp, one you use "/" for ""\" (or use "\\"). But in C#, it is not the case. Either use "\\" for "\" or use "@" precedes a "literal text string containing "\".
Are you sure BricsCAD exposes API that allows to use "\" in C# in a file path (since you said the first save is succeeded and only errors out on next drawing)?
Can you use Debug.Print/MessageBox to show variable p before SaveAs() is called to verify you do have a valid path?
Also, perhaps you use it later, but in the code shown, curDoc is declared but not used.
Sorry for a typo in my post:
"Are you sure BricsCAD exposes API that allows to use "\" in C# in a file path..."
Should be read as
"Are you sure BricsCAD exposes API that allows to use "/" in C# in a file path..."
So, my question still stands:
Are you saying that you can use a file path like this in C# (as if it is in Lisp)
string fileName = "C:/fodler1/folder2/folder3/theDwgFile.dwg";
Unless that is specificly allowed in BricsCAD (I have no idea what it is), in C#, it should be
string fileName = "C:\\fodler1\\folder2\\folder3\\theDwgFile.dwg";
or
string fielName=@"C:\fodler1\folder2\folder3\theDwgFile.dwg"
That is why I am curiuos how the first 1 or first 2 document could be saved as you claimed.
I removed the "destDoc.Close(true);" and now it works fine, strange...