VirtualPathProvider.FileExists(String) VirtualPathProvider.FileExists(String) VirtualPathProvider.FileExists(String) VirtualPathProvider.FileExists(String) Method

Definition

Gets a value that indicates whether a file exists in the virtual file system.

public:
 virtual bool FileExists(System::String ^ virtualPath);
public virtual bool FileExists (string virtualPath);
abstract member FileExists : string -> bool
override this.FileExists : string -> bool
Public Overridable Function FileExists (virtualPath As String) As Boolean

Parameters

virtualPath
String String String String

The path to the virtual file.

Returns

true if the file exists in the virtual file system; otherwise, false.

Examples

The following code example is an implementation of the FileExists method in a custom VirtualPathProvider class. For the full code required to run the example, see the Example section of the VirtualPathProvider class overview topic.

public override bool FileExists(string virtualPath)
{
  if (IsPathVirtual(virtualPath))
  {
    SampleVirtualFile file = (SampleVirtualFile)GetFile(virtualPath);
    return file.Exists;
  }
  else
    return Previous.FileExists(virtualPath);
}
Public Overrides Function FileExists(ByVal virtualPath As String) As Boolean
  If (IsPathVirtual(virtualPath)) Then
    Dim file As SampleVirtualFile
    file = CType(GetFile(virtualPath), SampleVirtualFile)
    Return file.Exists
  Else
    Return Previous.FileExists(virtualPath)
  End If
End Function

Remarks

Override the FileExists method to indicate to the compilation system that the resource represented by virtualPath exists in the virtual file system provided by this VirtualPathProvider instance.

Applies to