<?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 file open in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/check-if-file-open/m-p/3373149#M56805</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I added Imports&amp;nbsp;&lt;SPAN&gt;Microsoft.VisualBasic but it didn't support the problem&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 13px;"&gt;OpenMode.Binary is the only one it has a problem with it seems.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Mar 2012 21:11:01 GMT</pubDate>
    <dc:creator>SRSDS</dc:creator>
    <dc:date>2012-03-15T21:11:01Z</dc:date>
    <item>
      <title>Check if file open</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-if-file-open/m-p/3373069#M56801</link>
      <description>&lt;P&gt;I need to export data to an excel file but I need to check if the file is already open.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Searching the internet I found this but I don't know what "imports" to use to use to enable it.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    Public Function FileInUse(ByVal sFile As String) As Boolean
        If System.IO.File.Exists(sFile) Then
            Try
                Dim F As Short = FreeFile()
                FileOpen(F, sFile, OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.LockReadWrite)
                FileClose(F)
            Catch
                Return True
            End Try
        End If
    End Function&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2012 20:36:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-if-file-open/m-p/3373069#M56801</guid>
      <dc:creator>SRSDS</dc:creator>
      <dc:date>2012-03-15T20:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: Check if file open</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-if-file-open/m-p/3373085#M56802</link>
      <description>&lt;P&gt;Looks like you need to import Microsoft.VisualBasic to get the FileOpen and FileClose functions. You may want to change them to use IO.File.Open and IO.File.Close though, to get away from the old VB syntax.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Brent McAnney&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2012 20:44:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-if-file-open/m-p/3373085#M56802</guid>
      <dc:creator>BMcAnney</dc:creator>
      <dc:date>2012-03-15T20:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: Check if file open</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-if-file-open/m-p/3373137#M56804</link>
      <description>&lt;P&gt;I don't know what is the namespaces you use&lt;/P&gt;&lt;P&gt;in your program to work with Excel&lt;/P&gt;&lt;P&gt;Anyway you may want to try this function as well&lt;/P&gt;&lt;PRE&gt;   'Imports Microsoft.Office.Interop.Excel
    'Imports Excel = Microsoft.Office.Interop.Excel
    Public Function IsExcelFileOpen(xlapp As Microsoft.Office.Interop.Excel.Application, filename As String) As Boolean
        Dim isopen As Boolean = True
        Dim wbook As Microsoft.Office.Interop.Excel.Workbook
        Try
            wbook = xlapp.Workbooks(filename)
        Catch
            isopen = False
        End Try
        Return isopen
    End Function&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#339966" face="arial,helvetica,sans-serif"&gt;~'J'~&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2012 21:08:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-if-file-open/m-p/3373137#M56804</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-03-15T21:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: Check if file open</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-if-file-open/m-p/3373149#M56805</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I added Imports&amp;nbsp;&lt;SPAN&gt;Microsoft.VisualBasic but it didn't support the problem&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 13px;"&gt;OpenMode.Binary is the only one it has a problem with it seems.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2012 21:11:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-if-file-open/m-p/3373149#M56805</guid>
      <dc:creator>SRSDS</dc:creator>
      <dc:date>2012-03-15T21:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: Check if file open</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-if-file-open/m-p/3373163#M56806</link>
      <description>&lt;P&gt;Microsoft.VisualBasic.OpenMode.Binary&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2012 21:22:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-if-file-open/m-p/3373163#M56806</guid>
      <dc:creator>arcticad</dc:creator>
      <dc:date>2012-03-15T21:22:03Z</dc:date>
    </item>
  </channel>
</rss>

