Author Topic: Can file be opened, one method  (Read 19243 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Can file be opened, one method
« on: September 05, 2006, 01:47:40 PM »
Is there a better way to check if a file can be opened than this?  I couldn't find any other way to check.  This works.  It will return false if the file is read only, or is open already (at least with my testing with Acad dwgs it does).

Thanks in advance.
Code: [Select]
private bool CanBeOpened (string FullPath) {
bool CanOpen = false;
try {
using (FileStream fs = new FileStream (FullPath, FileMode.Open)) {
CanOpen = (fs.CanWrite);
}
}
catch {
}
if (CanOpen && ((File.GetAttributes (FullPath) & FileAttributes.ReadOnly) == 0)) {
return true;
}
else {
return false;
}
}
« Last Edit: September 05, 2006, 01:48:51 PM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Can file be opened, one method
« Reply #1 on: September 05, 2006, 06:06:01 PM »
how about something like

Code: [Select]
        private bool CanBeOpened(string FullPath)
        {
            FileStream fs = new FileStream(FullPath, FileMode.Open);
            if (fs.CanWrite && ((File.GetAttributes(FullPath) & FileAttributes.ReadOnly) == 0))
            {
                return true;
                // or do your stuff:
            }
            return false;
            // or raise an error:
        }

you could just paste the body of the method into your routine that is using the file (see comments) instead of creating a seperate function or if you still want to use a function, return the fs perhaps for use.
« Last Edit: September 05, 2006, 06:07:07 PM by MickD »
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Can file be opened, one method
« Reply #2 on: September 05, 2006, 06:48:14 PM »
I had something like that before, but it would crash when it couldn't open up a file.  I don't know enough to use a correct way of doing it, but I think it had something to do with the FileSteam calls though.  I will try this though, because maybe I had something different.  Thanks Mick.

Edit:  Yours thows the error also.  Thanks for trying Mick.
« Last Edit: September 05, 2006, 06:50:58 PM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Can file be opened, one method
« Reply #3 on: September 05, 2006, 07:01:06 PM »
Ok, it was more of a design example than an answer as your solution worked, what is the error you are getting?

Don't forget too that your fs object you created goes out of scope once the function returms! As I said, returning the fs would probably be a better option.

AND we were both missing an '&' in this line -
(File.GetAttributes(FullPath) & FileAttributes.ReadOnly)

 :laugh:
« Last Edit: September 05, 2006, 07:02:55 PM by MickD »
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Can file be opened, one method
« Reply #4 on: September 05, 2006, 07:10:54 PM »
Ok, it was more of a design example than an answer as your solution worked,
Oh, oops.   :-)

what is the error you are getting?
I can't tell.  It brings up a dialog box saying I don't have JIT installed, with only the options to debug (which never works for me) or continue.  So I hit continue, and the program seems to stop.

Don't forget too that your fs object you created goes out of scope once the function returms! As I said, returning the fs would probably be a better option.
I'm justing using the fs object to see if I can write to the drawing, as I open it with ObjectDBX.  I don't think (don't really know) you could use the fs object for what I'm doing, or planning on doing once I learn more, but I most certainly could be wrong.

AND we were both missing an '&' in this line -
(File.GetAttributes(FullPath) & FileAttributes.ReadOnly)

 :laugh:
Oops again.  I will get the hang of thins one day.

Thanks for helping.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Can file be opened, one method
« Reply #5 on: September 05, 2006, 07:18:37 PM »
surely ObjectDBX would have some way of telling you if you can read/write to a file??
The problem with your test is although you check to see if it's ok, what's to say that it's not ok by the time you go to actually write to the file, you really do need to 'have' the file to work on it without error. Unlikely I know but...

I haven't used dbx before but I'd imagine it would be like working directly on the database which has it's own ways of letting you know if it's available (ErrorStatus results returned for example).
I take it that you are using this as a stand alone app not associated with AutoCAD?
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Can file be opened, one method
« Reply #6 on: September 05, 2006, 07:34:07 PM »
surely ObjectDBX would have some way of telling you if you can read/write to a file??
The problem with your test is although you check to see if it's ok, what's to say that it's not ok by the time you go to actually write to the file, you really do need to 'have' the file to work on it without error. Unlikely I know but...

I haven't used dbx before but I'd imagine it would be like working directly on the database which has it's own ways of letting you know if it's available (ErrorStatus results returned for example).

ObjectDBX is just a way to open a drawing without loading it into the editor, so it acts almost just like the database of any drawing.  I have tried to just open the DBX doc, but that didn't work either.  Now I open the drawing right after I test it, and do my changes to it then, and then test the next one if it can be opened.  Maybe this is just to big for me to have as my first attempt at a real project.  I mean I got it to work, but I'm sure it can be made to run faster/smoother/smarter... etc.  If that is the case, then I will just do as much research as I can, instead of asking so many questions.  I really do appreciate all the help I have been given, and I don't want to seem like a leach.

I take it that you are using this as a stand alone app not associated with AutoCAD?
Na, this will be called from within Acad.  I think you have to pay for a licence for 'RealDwg' to use ObjectDBX without Acad installed, and I'm sure my company won't pay for that since I'm just beginning, and they have real programmers who know what they are doing.  :-D

If you think it would help I can post the code, but its long (around 300 lines), and I don't think people want to read the whole thing to try and find the couple of lines that may make it faster, I know I don't when I'm trying to help someone with there code, that they wrote.  :-D

Thanks again for all the help, I really do appreciate it.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Can file be opened, one method
« Reply #7 on: September 05, 2006, 07:44:06 PM »
Quote
Na, this will be called from within Acad...
Mate!?!,
what are you doing with dbx then, you can open a db and alter it with the managed wrappers without using the editor!
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Can file be opened, one method
« Reply #8 on: September 05, 2006, 07:57:40 PM »
Quote
Na, this will be called from within Acad...
Mate!?!,
what are you doing with dbx then, you can open a db and alter it with the managed wrappers without using the editor!
:oops:
I don't know how to do it.  I just knew it can be done with DBX because of my background with lisp.  I didn't know it could be done that way.  I guess I will look into doing it that way tomorrow when I have my Acad close to me.  Can you give me a starting point for my reseach tomorrow?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Glenn R

  • Guest
Re: Can file be opened, one method
« Reply #9 on: September 05, 2006, 08:30:10 PM »
Sure can...hang a sec...

Glenn R

  • Guest
Re: Can file be opened, one method
« Reply #10 on: September 05, 2006, 08:36:02 PM »
The code below is from one of my templates for doing in-memory batch runs over drawings.
It is in the click event for the 'ok' button on the dialog:

Code: [Select]
foreach (string drawingName in listBoxDrgs.Items) {

try {

// Create a new pristine dbase...
using (Database db = new Database(false, true)) {

using (Transaction tr = db.TransactionManager.StartTransaction()) {

//...and read in the dwg...
db.ReadDwgFile(drawingName, System.IO.FileShare.Read, true, null);
ed.WriteMessage("\nSome prompt mojo...drawing: {0}", drawingName);

tr.Commit(); // Optional depending on what you're doing...
}

db.SaveAs(drawingName, DwgVersion.Current);

}// database goes out of scope here...

} catch (System.Exception ex) {
// Do something here with exception...
}

}//foreach

I suggest you study it (look up functions in the ARX and Windows docs) and ask questions here.
Pay particular attention to the constructor of the new Database...

Cheers,
Glenn.
« Last Edit: September 05, 2006, 08:38:16 PM by Glenn R »

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Can file be opened, one method
« Reply #11 on: September 05, 2006, 08:57:01 PM »
Thanks Glenn, I didn't have anything that tidy that would not take an hour to clean up and post :)

This is the best way Tim, you can create and edit complete drawings without ever opening the drg in the editor.
Have fun.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Can file be opened, one method
« Reply #12 on: September 05, 2006, 10:47:21 PM »
Thank you both!!!  I will study this tomorrow at work, when I have all the documentation.

Is there any need than for ObjectDBX with .Net applications, if you only would use it within Acad?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Glenn R

  • Guest
Re: Can file be opened, one method
« Reply #13 on: September 05, 2006, 11:06:18 PM »
Let's get some terminology clear.

ObjectDBX (now RealDWG) is a set of C++ libraries available by license, that allows you to create stand-alone windows programs that read and write dwg WITHOUT Autocad being present.

What you're referring to here, is the COM typelibrary that comes with AutoCAD and needs AutoCAD to run - 2 different beasts.

In answer to your question, no there is no reason to use 'ObjectDBX COM' if you're using .NET (well almost none). You can create a new database and read a dwg into like I demonstrated above. This is markedly faster than using 'ObjectDBX COM' as well.

Hope this helps.

Cheers,
Glenn.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Can file be opened, one method
« Reply #14 on: September 05, 2006, 11:37:54 PM »
Let's get some terminology clear.

ObjectDBX (now RealDWG) is a set of C++ libraries available by license, that allows you to create stand-alone windows programs that read and write dwg WITHOUT Autocad being present.

What you're referring to here, is the COM typelibrary that comes with AutoCAD and needs AutoCAD to run - 2 different beasts.

In answer to your question, no there is no reason to use 'ObjectDBX COM' if you're using .NET (well almost none). You can create a new database and read a dwg into like I demonstrated above. This is markedly faster than using 'ObjectDBX COM' as well.

Hope this helps.

Cheers,
Glenn.
That does help a lot Glenn.  Thanks again.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Can file be opened, one method
« Reply #15 on: September 06, 2006, 11:50:53 AM »
Glenn,

  So in your code you are saying to make a new Database and to not use the current drawing (first argument, set to false) and that you don't want any drawing associated with it right now (second argument, set to true)?

Then you open a drawing's database with 'ReadDwgFile', give it the full path (first argument) and then how you want the OS to handle what others are able to do when they try to open it when the code has it opened already (second argument).  I don't understand what the third argument is for, in SharpDevelop it states that the third argument is for 'allowCPConversion'.  And then the last argument is the password, which would be false to all of my drawings.

I'm guess (as I haven't tried it yet) that if it can't be open, then it will throw an error, which is why you put it into a 'try catch' phrase.

Thanks again.  I'm off to see if I can find something about 'allowCPConversion' on the net.  This is getting fun.  :-)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Alexander Rivilis

  • Bull Frog
  • Posts: 214
  • Programmer from Kyiv (Ukraine)
Re: Can file be opened, one method
« Reply #16 on: September 06, 2006, 12:02:48 PM »
... I'm off to see if I can find something about 'allowCPConversion' on the net...
If you are writing application only for USA customers you can ignore allowCPConversion. It is mean Allow CodePage Conversion - e.g. conversion from code page in which this dwg-file was creating/editing last time to curren System CodePage (Windows CodePage). I  prefer allowCPConversion = false
« Last Edit: September 06, 2006, 12:11:20 PM by Alexander Rivilis »

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Can file be opened, one method
« Reply #17 on: September 06, 2006, 12:09:18 PM »
... I'm off to see if I can find something about 'allowCPConversion' on the net...
If you are writing application only fo USA customers you can ignore allowCPConversion. It is mean Allow CodePage Conversation - e.g. conversation from code page in which this dwg-file was creating/editing last time to curren System CodePage (Windows CodePage). I  prefer allowCPConversion = false
Thanks Alexander.  I'm only writing for myself right now, so US only, so I will do as you advise.  :-)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Alexander Rivilis

  • Bull Frog
  • Posts: 214
  • Programmer from Kyiv (Ukraine)
Re: Can file be opened, one method
« Reply #18 on: September 06, 2006, 12:10:47 PM »
 :-D

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Can file be opened, one method
« Reply #19 on: September 06, 2006, 01:04:36 PM »
The problem with doing it this way is that the attributes don't get saved in the correct location.  When going the DBX route the attributes stay in the correct location.

Thanks for the lession.  If I have to update attributes (not left justified) then it seems I have to use DBX, but if not, then I can go with just opening the database and making changes.

Attachments show what I'm talking about.  The weird thing is, when you open the drawing, and move (or do any command to) the block (db-route) the attribute will move to the correct location.
« Last Edit: September 06, 2006, 01:05:49 PM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Alexander Rivilis

  • Bull Frog
  • Posts: 214
  • Programmer from Kyiv (Ukraine)
Re: Can file be opened, one method
« Reply #20 on: September 06, 2006, 01:07:22 PM »
The problem with doing it this way is that the attributes don't get saved in the correct location.  When going the DBX route the attributes stay in the correct location.
Are you remeber about Tony WorkingDatabase class?
« Last Edit: September 06, 2006, 01:08:38 PM by Alexander Rivilis »

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Can file be opened, one method
« Reply #21 on: September 06, 2006, 01:15:47 PM »
The problem with doing it this way is that the attributes don't get saved in the correct location.  When going the DBX route the attributes stay in the correct location.
Are you remeber about Tony WorkingDatabase class?
I didn't code that in.  I thought what Glenn posted was all I needed.  I can try that also then.  Be back in a little.. have to test it.  Thanks for pointing that out Alexander.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Can file be opened, one method
« Reply #22 on: September 06, 2006, 02:50:05 PM »
So with what Mick and Glenn said; Use Database to open drawings and make changes.

And what Alexander reminded me of what Tony said; Make sure that the Database you want to change is the current working database.

I came up with this (just a section of the code) that seems to be working correctly.  Is this a safe way to do it?

Any comments/suggestions welcomed.  Thanks in advance, and thanks for the help so far.

Code: [Select]
foreach (string Str in DwgList) {
      bool ShouldSave = false;
      //Database db = new Database (false, true);
      try {
      using (Database db = new Database (false, true)) {
      db.ReadDwgFile (Str, System.IO.FileShare.Read, true, null);
      if (db != HostApplicationServices.WorkingDatabase) {
      HostApplicationServices.WorkingDatabase = db;
      }
      if (HasLayer (db, "Cloud-UNKNOWN")) {
string Rev = (GetHighestRev(db));
if (Rev != "") {
UpdateRevBlock (db, Rev);
UpdateCloudLayer (db, "Cloud-UNKNOWN", "Cloud-" + Rev);
ShouldSave = true;
//MessageBox.Show ("Right before save.");
}
}
        if (ShouldSave == true) {
    db.RetainOriginalThumbnailBitmap = true;
db.SaveAs (Str, DwgVersion.Current);
      SaveAr[SaveCnt] = Str;
++SaveCnt;
        }
else {
DiscardAr[DiscardCnt] = Str;
++DiscardCnt;
}
      //db.Dispose();
      }
      }
      catch {
      CannotOpenAr[CannotOpenCnt] = Str;
      ++CannotOpenCnt;
      }
}
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Can file be opened, one method
« Reply #23 on: September 06, 2006, 03:23:01 PM »
I had to put in one for check.  I had to check to make sure the file wasn't read only before I tried to open it's database.  I tried it without checking, and Acad threw up and error message, and then crashed to the desktop.

Thanks again for all the help, and knowledge shared.  :-) :love:
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Glenn R

  • Guest
Re: Can file be opened, one method
« Reply #24 on: September 06, 2006, 06:30:03 PM »
Glenn,

  So in your code you are saying to make a new Database and to not use the current drawing (first argument, set to false) and that you don't want any drawing associated with it right now (second argument, set to true)?

Then you open a drawing's database with 'ReadDwgFile', give it the full path (first argument) and then how you want the OS to handle what others are able to do when they try to open it when the code has it opened already (second argument).  I don't understand what the third argument is for, in SharpDevelop it states that the third argument is for 'allowCPConversion'.  And then the last argument is the password, which would be false to all of my drawings.

I'm guess (as I haven't tried it yet) that if it can't be open, then it will throw an error, which is why you put it into a 'try catch' phrase.

Thanks again.  I'm off to see if I can find something about 'allowCPConversion' on the net.  This is getting fun.  :-)

Pretty much correct on all counts there Tim.
Changing the working dbase to the one you open in memory I suspect allows AutoCAD to do the justification/position mojo you are talking about, although I've never needed to or tried it myself.

Fun isn't it? :)

Cheers,
Glenn.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Can file be opened, one method
« Reply #25 on: September 06, 2006, 06:33:55 PM »
Glenn,

  So in your code you are saying to make a new Database and to not use the current drawing (first argument, set to false) and that you don't want any drawing associated with it right now (second argument, set to true)?

Then you open a drawing's database with 'ReadDwgFile', give it the full path (first argument) and then how you want the OS to handle what others are able to do when they try to open it when the code has it opened already (second argument).  I don't understand what the third argument is for, in SharpDevelop it states that the third argument is for 'allowCPConversion'.  And then the last argument is the password, which would be false to all of my drawings.

I'm guess (as I haven't tried it yet) that if it can't be open, then it will throw an error, which is why you put it into a 'try catch' phrase.

Thanks again.  I'm off to see if I can find something about 'allowCPConversion' on the net.  This is getting fun.  :-)

Pretty much correct on all counts there Tim.
Changing the working dbase to the one you open in memory I suspect allows AutoCAD to do the justification/position mojo you are talking about, although I've never needed to or tried it myself.
Cool thanks.  I think I'm starting to understand this (with all the help from people here).

Fun isn't it? :)

Cheers,
Glenn.
Very much so.  I love to learn, and when you can learn something that is useful, that is even better.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Glenn R

  • Guest
Re: Can file be opened, one method
« Reply #26 on: September 06, 2006, 06:36:50 PM »
here is my catch clause that I left out:

Code: [Select]
catch (Autodesk.AutoCAD.Runtime.Exception aex) {

if (stringBuilder == null)
stringBuilder = new StringBuilder();

if (aex.ErrorStatus == ErrorStatus.FileSharingViolation)
stringBuilder.AppendFormat("\n{0} is already open!", drawingName);
else if (aex.ErrorStatus == ErrorStatus.DwgNeedsRecovery)
stringBuilder.AppendFormat("\n{0} needs recovery!", drawingName);
else if (aex.ErrorStatus == ErrorStatus.BadDwgHeader)
stringBuilder.AppendFormat("\n{0} has a bad drawing header!", drawingName);
else
stringBuilder.AppendFormat("\n{0} has error {1}", drawingName, aex.Message);

continue;

} catch (System.Exception ex) {

ed.WriteMessage("\nError: {0}", ex.Message);
ed.WriteMessage("\nStack trace: {0}", ex.StackTrace);
return;

}

Also, I don't see you resetting the working dbase after you change it.......?????


T.Willey

  • Needs a day job
  • Posts: 5251
Re: Can file be opened, one method
« Reply #27 on: September 06, 2006, 06:54:17 PM »
here is my catch clause that I left out:

<snip>
Thanks.  This will be useful.

Also, I don't see you resetting the working dbase after you change it.......?????

Guess I didn't know I had to.  Would I do it like?
Code: [Select]
Document Doc = Autodesk.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Database DocDb = Doc.Database;
if (DocDb != HostApplicationServices.WorkingDatabase) {
    HostApplicationServices.WorkingDatabase = DocDb;
}
Or could I just set it without checking?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: Can file be opened, one method
« Reply #28 on: September 06, 2006, 07:10:19 PM »
reset?

I have done something similar using objectarx... and I simple call the delete operator - only when working with an external file....


Or this reset part is something particular only when using C# ?....


Thanks
« Last Edit: September 06, 2006, 07:11:36 PM by LE »

Glenn R

  • Guest
Re: Can file be opened, one method
« Reply #29 on: September 06, 2006, 07:20:55 PM »
When you fire your command, the working database in essence is the drawing/document your command was executed in.
You then reset it, but I never saw where you put it back to the original when it first started.

Tony's class did this automatically, as his class was implementing the IDisposable interface. Essentially, this means it can be used with a 'using' statement. When a 'using' statement's scope ends, it's destructor/dispose method is called and THAT's where Tony was resetting the working database back to the one he cached, which was passed in in the class's constructor...make sense?

Tony's class is essentially operating like a 'smart pointer' class/object in C++.

Cheers,
Glenn.
« Last Edit: September 06, 2006, 07:23:10 PM by Glenn R »

LE

  • Guest
Re: Can file be opened, one method
« Reply #30 on: September 06, 2006, 07:25:54 PM »
...make sense?

Yep....

Claro como el lodo Glenn -  :-)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Can file be opened, one method
« Reply #31 on: September 06, 2006, 07:28:27 PM »
So then if I set it back after the first foreach statement, then it should be all good?  That is how I have it right now.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Glenn R

  • Guest
Re: Can file be opened, one method
« Reply #32 on: September 06, 2006, 07:31:44 PM »
BTW, Tony did make SPECIFIC mention, that if you change the owrking database for whatever reason, make VERY sure you reset when you're done or Acad could become unstable at best, crash at worst.

Quote
So then if I set it back after the first foreach statement


I suppose you could, but you would want to make damn sure that any possible error is trapped and if fatal enough, reset the working database back in the catch.

LE, the 'using' statement with the 'new database' makes sure the new database is deleted (C++) / disposed (C#) when the using statement's scope ends.

Cheers,
Glenn.
« Last Edit: September 06, 2006, 07:33:06 PM by Glenn R »

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Can file be opened, one method
« Reply #33 on: September 06, 2006, 07:33:54 PM »
Thanks for keeping an eye on my coding Glenn.  It is very helpful, and I appreciate it.  :-)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Can file be opened, one method
« Reply #34 on: September 06, 2006, 07:46:01 PM »
Thanks for keeping an eye on my coding Glenn.  It is very helpful, and I appreciate it.  :-)

... as do we all. Thanks for the illumination Glenn.

//kwb
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

LE

  • Guest
Re: Can file be opened, one method
« Reply #35 on: September 06, 2006, 07:46:24 PM »
Thank you Glenn.

Quote
Claro como el lodo -> clear as mud....

Tim;

For some reason your code posted has a lot of squares characters and it is somehow confused at least for my eyes.... and yes you have the call of "using" statement.... before opening the new database....

Thanks.

Glenn R

  • Guest
Re: Can file be opened, one method
« Reply #36 on: September 06, 2006, 08:07:26 PM »
The squares are from me - tab characters/spaces that I was trying to remove/got added, to get the formatting right when I pasted in the code.

Yes, Tim does have the 'using' for the new database, however the issue I was referring to was the WorkingDatabase and the changing and resetting of it.

To all, you're welcome.

Cheers,
Glenn.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Can file be opened, one method
« Reply #37 on: September 06, 2006, 09:38:45 PM »
... as do we all. Thanks for the illumination Glenn.

Indeed.

Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst