<?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 Re: Check if drawing is open by another user *before opening*? VB.NET in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/check-if-drawing-is-open-by-another-user-before-opening-vb-net/m-p/1794787#M80086</link>
    <description>Looks like you need to set your opened file to an object before you can close it.&lt;BR /&gt;
&lt;BR /&gt;
Function IsFileOpen(ByVal FileName As String) As Boolean&lt;BR /&gt;
Dim FileTest As Object&lt;BR /&gt;
Try&lt;BR /&gt;
FileTest = System.IO.File.Open(FileName, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.None)&lt;BR /&gt;
IsFileOpen = False&lt;BR /&gt;
FileTest.Close()&lt;BR /&gt;
Catch ex As Exception&lt;BR /&gt;
IsFileOpen = True&lt;BR /&gt;
End Try&lt;BR /&gt;
End Function</description>
    <pubDate>Wed, 18 Oct 2006 15:43:43 GMT</pubDate>
    <dc:creator>Mikko</dc:creator>
    <dc:date>2006-10-18T15:43:43Z</dc:date>
    <item>
      <title>Check if drawing is open by another user *before opening*? VB.NET</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-if-drawing-is-open-by-another-user-before-opening-vb-net/m-p/1794786#M80085</link>
      <description>Is there a way to check if a file is open by another user before you open &lt;BR /&gt;
it? I know once a file is open, I can use the ThisDrawing.ReadOnly property &lt;BR /&gt;
to check it.  I was just trying to save some time by not having to open a &lt;BR /&gt;
drawing before processing it.&lt;BR /&gt;
&lt;BR /&gt;
There doesn't seem to be a property under System.IO.File to handle this. &lt;BR /&gt;
I've tried this code:&lt;BR /&gt;
Public Shared Function IsFileOpen(ByVal filename As String) As Boolean&lt;BR /&gt;
    Try&lt;BR /&gt;
        System.IO.File.Open(filename, IO.FileMode.Open,IO.FileAccess.Read, &lt;BR /&gt;
IO.FileShare.None)&lt;BR /&gt;
        FileClose(1)&lt;BR /&gt;
        Return False&lt;BR /&gt;
    Catch ex As Exception&lt;BR /&gt;
        Return True&lt;BR /&gt;
    End Try&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
But it seems to change the properies of the drawing so AutoCAD won't open &lt;BR /&gt;
it.  Any help would be appreciated!</description>
      <pubDate>Wed, 18 Oct 2006 13:49:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-if-drawing-is-open-by-another-user-before-opening-vb-net/m-p/1794786#M80085</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-10-18T13:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: Check if drawing is open by another user *before opening*? VB.NET</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-if-drawing-is-open-by-another-user-before-opening-vb-net/m-p/1794787#M80086</link>
      <description>Looks like you need to set your opened file to an object before you can close it.&lt;BR /&gt;
&lt;BR /&gt;
Function IsFileOpen(ByVal FileName As String) As Boolean&lt;BR /&gt;
Dim FileTest As Object&lt;BR /&gt;
Try&lt;BR /&gt;
FileTest = System.IO.File.Open(FileName, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.None)&lt;BR /&gt;
IsFileOpen = False&lt;BR /&gt;
FileTest.Close()&lt;BR /&gt;
Catch ex As Exception&lt;BR /&gt;
IsFileOpen = True&lt;BR /&gt;
End Try&lt;BR /&gt;
End Function</description>
      <pubDate>Wed, 18 Oct 2006 15:43:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-if-drawing-is-open-by-another-user-before-opening-vb-net/m-p/1794787#M80086</guid>
      <dc:creator>Mikko</dc:creator>
      <dc:date>2006-10-18T15:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: Check if drawing is open by another user *before opening*? VB.NET</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-if-drawing-is-open-by-another-user-before-opening-vb-net/m-p/1794788#M80087</link>
      <description>VB.Net 2005:&lt;BR /&gt;
&lt;BR /&gt;
  Function FileInUse(ByVal FN As String) As Boolean&lt;BR /&gt;
    Try&lt;BR /&gt;
      Using fs As IO.FileStream = IO.File.Open(FN, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.None)&lt;BR /&gt;
        Return False&lt;BR /&gt;
      End Using&lt;BR /&gt;
    Catch ex As IO.IOException&lt;BR /&gt;
      Return True&lt;BR /&gt;
    End Try&lt;BR /&gt;
  End Function&lt;BR /&gt;
&lt;BR /&gt;
&amp;lt;= VB.NET 2003:&lt;BR /&gt;
&lt;BR /&gt;
  Function FileInUse(ByVal FN As String) As Boolean&lt;BR /&gt;
    Dim fs As IO.FileStream = Nothing&lt;BR /&gt;
    Try&lt;BR /&gt;
      fs = IO.File.Open(FN, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.None)&lt;BR /&gt;
      Return False&lt;BR /&gt;
    Catch ex As IO.IOException&lt;BR /&gt;
      Return True&lt;BR /&gt;
    Finally&lt;BR /&gt;
      If Not fs Is Nothing Then&lt;BR /&gt;
        fs.Close()&lt;BR /&gt;
      End If&lt;BR /&gt;
    End Try&lt;BR /&gt;
  End Function&lt;BR /&gt;
&lt;BR /&gt;
C</description>
      <pubDate>Wed, 18 Oct 2006 18:07:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-if-drawing-is-open-by-another-user-before-opening-vb-net/m-p/1794788#M80087</guid>
      <dc:creator>cgay</dc:creator>
      <dc:date>2006-10-18T18:07:09Z</dc:date>
    </item>
  </channel>
</rss>

