C# .NET Document SaveAs

C# .NET Document SaveAs

oransen
Collaborator Collaborator
2,109 Views
1 Reply
Message 1 of 2

C# .NET Document SaveAs

oransen
Collaborator
Collaborator

I don't seem to have the .SaveAs function of a Document...SaveAs.png

 

I must have forgotten to twiddle a lever or push a button somewhere...

0 Likes
Accepted solutions (1)
2,110 Views
1 Reply
Reply (1)
Message 2 of 2

oransen
Collaborator
Collaborator
Accepted solution

Ooops. Forget it. I must study more. Here's the code I got to work.

 

            using (Database db = new Database(false, true))
            {
                db.ReadDwgFile(sSourceFullFileName, FileOpenMode.OpenForReadAndReadShare, false, "");

                // closing the input makes sure the whole dwg is read from disk
                // it also closes the file so you can SaveAs the same name
                db.CloseInput(true);

                // store the current working database, to reset
                Database currDb = HostApplicationServices.WorkingDatabase;

                // set working database
                HostApplicationServices.WorkingDatabase = db;

                // { Do Some Work}

                db.SaveAs(sFullDestFileName, DwgVersion.Current);

                // reset the working database
                HostApplicationServices.WorkingDatabase = currDb;
            }

I picked it up in a desperate search in the forums...

0 Likes