ItemOperations::IsFileOpen Method (String^, String^)
Visual Studio 2015
Indicates whether or not the specified saved file is currently open in the specified view.
Assembly: EnvDTE (in EnvDTE.dll)
bool IsFileOpen( String^ FileName, String^ ViewKind = "{FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF}" )
Parameters
- FileName
-
Type:
System::String^
Required. The absolute path to the specified saved file. If the file has just been created but not yet saved, then IsFileOpen returns false.
- ViewKind
-
Type:
System::String^
Optional. A Constants .vsViewKind* constant representing the type of view in which the saved file is currently open.
Return Value
Type: System::BooleanA Boolean value indicating true if the file is open in the specified view, false if not.
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
Show: