VirtualPathProvider.FileExists(String) Método

Definição

Obtém um valor que indica se um arquivo existe no sistema de arquivos virtual.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

Parâmetros

virtualPath
String

O caminho para o arquivo virtual.The path to the virtual file.

Retornos

Boolean

true se o arquivo existir no sistema de arquivos virtual; caso contrário, false.true if the file exists in the virtual file system; otherwise, false.

Exemplos

O exemplo de código a seguir é uma implementação do FileExists método em uma VirtualPathProvider classe personalizada.The following code example is an implementation of the FileExists method in a custom VirtualPathProvider class. Para obter o código completo necessário para executar o exemplo, consulte a seção de exemplo do VirtualPathProvider tópico Visão geral da classe.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

Comentários

Substitua o FileExists método para indicar ao sistema de compilação que o recurso representado por virtualPath existe no sistema de arquivos virtual fornecido por essa VirtualPathProvider instância.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.

Aplica-se a