VB.net check whether a file is opened or not

前端之家收集整理的这篇文章主要介绍了VB.net check whether a file is opened or not前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Dim excel_file_opened As Boolean = False

Private Sub Test(ByRef sName As String)

Dim fs As FileStream
Try
fs = File.Open(sName,FileMode.Open,FileAccess.Read,FileShare.None)
excel_file_opened = False
fs.Close() Catch ex As Exception excel_file_opened = True End Try End Sub

猜你在找的VB相关文章