<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Read unopened dwg file give fileaccesserr in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/read-unopened-dwg-file-give-fileaccesserr/m-p/11074774#M13311</link>
    <description>&lt;P&gt;Sorry for asking this, I'm sure i'm doing something stupid, but can't get it to work and can't find the answer. Tried several combinations, all give me a efileaccesserr when trying to read unopened dwg-file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for example by:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Database db = new Database(false, true);
using (db)
{db.ReadDwgFile(path, FileOpenMode.OpenForReadAndAllShare, true, "");&lt;/LI-CODE&gt;&lt;P&gt;or even with:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;DocumentCollection acDocMgr=Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager;
Document acNewDoc = acDocMgr.Add(path);&lt;/LI-CODE&gt;&lt;P&gt;it immediatly gives me the error. it's the first lines in my code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the "path"variable contains the path, as you might have expected.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 31 Mar 2022 18:59:10 GMT</pubDate>
    <dc:creator>stefanveurink68AXD</dc:creator>
    <dc:date>2022-03-31T18:59:10Z</dc:date>
    <item>
      <title>Read unopened dwg file give fileaccesserr</title>
      <link>https://forums.autodesk.com/t5/net-forum/read-unopened-dwg-file-give-fileaccesserr/m-p/11074774#M13311</link>
      <description>&lt;P&gt;Sorry for asking this, I'm sure i'm doing something stupid, but can't get it to work and can't find the answer. Tried several combinations, all give me a efileaccesserr when trying to read unopened dwg-file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for example by:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Database db = new Database(false, true);
using (db)
{db.ReadDwgFile(path, FileOpenMode.OpenForReadAndAllShare, true, "");&lt;/LI-CODE&gt;&lt;P&gt;or even with:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;DocumentCollection acDocMgr=Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager;
Document acNewDoc = acDocMgr.Add(path);&lt;/LI-CODE&gt;&lt;P&gt;it immediatly gives me the error. it's the first lines in my code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the "path"variable contains the path, as you might have expected.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 18:59:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/read-unopened-dwg-file-give-fileaccesserr/m-p/11074774#M13311</guid>
      <dc:creator>stefanveurink68AXD</dc:creator>
      <dc:date>2022-03-31T18:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: Read unopened dwg file give fileaccesserr</title>
      <link>https://forums.autodesk.com/t5/net-forum/read-unopened-dwg-file-give-fileaccesserr/m-p/11076117#M13312</link>
      <description>&lt;P&gt;By the way, should have mentioned I'm trying to read an dwg file that's not opened in autocad. I need to find out which layouts are in it. But to know that I first have to access it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tried to docklock it but then I first need to call it a document, what i'm trying to do with the second piece of code. But don't even get the chance to call it a document cause even there I get the eFileAccesErr. If the dwg file would be open doclock it would be easy, there's no trouble with that.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2022 10:13:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/read-unopened-dwg-file-give-fileaccesserr/m-p/11076117#M13312</guid>
      <dc:creator>stefanveurink68AXD</dc:creator>
      <dc:date>2022-04-01T10:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: Read unopened dwg file give fileaccesserr</title>
      <link>https://forums.autodesk.com/t5/net-forum/read-unopened-dwg-file-give-fileaccesserr/m-p/11076238#M13313</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;There's nothing wrong in the little snippet you posted. The issue is elsewhere, perhaps in the file itself or its path.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try with someting like this:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;        [CommandMethod("TEST")]
        public static void Test()
        {
            var ofd = new OpenFileDialog() { 
                Filter = "Drawings (*.dwg)|*.dwg", 
                Title = "File to get layouts from" };
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                var layoutNames = new List&amp;lt;string&amp;gt;();
                using (var db = new Database(false, true))
                {
                    db.ReadDwgFile(ofd.FileName, FileOpenMode.OpenForReadAndAllShare, true, "");
                    using (var tr = db.TransactionManager.StartOpenCloseTransaction())
                    {
                        var layouts = (DBDictionary)tr.GetObject(db.LayoutDictionaryId, OpenMode.ForRead);
                        foreach (DBDictionaryEntry entry in layouts)
                        {
                            layoutNames.Add(entry.Key);
                        }
                        tr.Commit();
                    }
                }
                AcAp.ShowAlertDialog(string.Join("\n", layoutNames));
            }
        }&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 01 Apr 2022 11:54:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/read-unopened-dwg-file-give-fileaccesserr/m-p/11076238#M13313</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2022-04-01T11:54:35Z</dc:date>
    </item>
  </channel>
</rss>

