VirtualPathProvider.FileExists(String) Method

Definition

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

C#
public virtual bool FileExists(string virtualPath);

Parameters

virtualPath
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.

C#
public override bool FileExists(string virtualPath)
{
  if (IsPathVirtual(virtualPath))
  {
    SampleVirtualFile file = (SampleVirtualFile)GetFile(virtualPath);
    return file.Exists;
  }
  else
        {
            return Previous.FileExists(virtualPath);
        }
    }

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

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1