VirtualPathProvider.FileExists(String) Metoda

Definicja

Pobiera wartość wskazującą, czy plik istnieje w wirtualnym systemie plików.

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

Parametry

virtualPath
String

Ścieżka do pliku wirtualnego.

Zwraca

Boolean

true jeśli plik istnieje w wirtualnym systemie plików; w przeciwnym razie , false.

Przykłady

Poniższy przykład kodu to implementacja FileExists metody w klasie niestandardowej VirtualPathProvider . Pełny kod wymagany do uruchomienia przykładu można znaleźć w sekcji Przykład tematu VirtualPathProvider przeglądu klasy.

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

Uwagi

Zastąpij metodę FileExists , aby wskazać system kompilacji, że zasób reprezentowany przez virtualPath program istnieje w wirtualnym systemie plików dostarczonym przez to VirtualPathProvider wystąpienie.

Dotyczy