ItemOperations.IsFileOpen 方法

表示所指定的儲存檔目前是否在指定檢視中開啟。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.dll 中)

語法

'宣告
Function IsFileOpen ( _
    FileName As String, _
    ViewKind As String _
) As Boolean
bool IsFileOpen(
    string FileName,
    string ViewKind
)
bool IsFileOpen(
    [InAttribute] String^ FileName, 
    [InAttribute] String^ ViewKind
)
abstract IsFileOpen : 
        FileName:string * 
        ViewKind:string -> bool 
function IsFileOpen(
    FileName : String, 
    ViewKind : String
) : boolean

參數

  • FileName
    型別:System.String
    必要項。到指定儲存檔的絕對路徑,如果檔案剛建立而尚未儲存,IsFileOpen 就會傳回 false。
  • ViewKind
    型別:System.String
    選擇項。Constants .vsViewKind* 常數表示目前開啟此儲存檔所在之檢視的類型。

傳回值

型別:System.Boolean
如果檔案在指定檢視中開啟,則布林值表示為 true,否則為 false。

範例

Sub IsFileOpenExample()
    Dim soln As Solution = DTE.Solution
    Dim prj As Project
    Dim prjItem As ProjectItem
    Dim ItemOp As ItemOperations
    Dim savePath As String

    ' Create a new text document.
    ItemOp = DTE.ItemOperations
    ItemOp.NewFile("General\Text File", "Some name", _
    Constants.vsViewKindTextView)

    ' Set variables for proj and proj item names.
    prj = soln.Item(1)
    prjItem = prj.ProjectItems.Item(1)
    savePath = "C:\UserFiles\KempB\" & prjItem.Name
    MsgBox(savePath)

    If ItemOp.IsFileOpen(savePath) = True Then
        MsgBox("The saved document is open.")
    Else
        MsgBox("The saved document is not open.")
    End If

    prjItem.Save(savePath)
        
    If ItemOp.IsFileOpen(savePath) = True Then
        MsgBox("The saved document is open.")
    Else
        MsgBox("The saved document is not open.")
    End If
End Sub

.NET Framework 安全性

請參閱

參考

ItemOperations 介面

EnvDTE 命名空間