Share via


IsolatedStorageFile.GetFileNames Metoda

Definice

Vytvoří výčet názvů souborů v kořenovém adresáři izolovaného úložiště.

Přetížení

GetFileNames()

Vytvoří výčet názvů souborů v kořenovém adresáři izolovaného úložiště.

GetFileNames(String)

Získá názvy souborů, které odpovídají vzoru hledání.

GetFileNames()

Zdroj:
IsolatedStorageFile.cs
Zdroj:
IsolatedStorageFile.cs
Zdroj:
IsolatedStorageFile.cs

Vytvoří výčet názvů souborů v kořenovém adresáři izolovaného úložiště.

public:
 cli::array <System::String ^> ^ GetFileNames();
public string[] GetFileNames ();
[System.Runtime.InteropServices.ComVisible(false)]
public string[] GetFileNames ();
member this.GetFileNames : unit -> string[]
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.GetFileNames : unit -> string[]
Public Function GetFileNames () As String()

Návraty

String[]

Pole relativních cest k souborům v kořenovém adresáři izolovaného úložiště. Pole nulové délky určuje, že v kořenovém adresáři nejsou žádné soubory.

Atributy

Výjimky

Izolované úložiště bylo odebráno.

Izolované úložiště bylo odstraněno.

Cesty k souborům z kořenového adresáře izolovaného úložiště nelze určit.

Poznámky

Tato metoda je ekvivalentní použití IsolatedStorageFile.GetFileNames(String) metody se zadaným znakem *pro vzor vyhledávání.

Viz také

Platí pro

GetFileNames(String)

Zdroj:
IsolatedStorageFile.cs
Zdroj:
IsolatedStorageFile.cs
Zdroj:
IsolatedStorageFile.cs

Získá názvy souborů, které odpovídají vzoru hledání.

public:
 cli::array <System::String ^> ^ GetFileNames(System::String ^ searchPattern);
public string[] GetFileNames (string searchPattern);
member this.GetFileNames : string -> string[]
Public Function GetFileNames (searchPattern As String) As String()

Parametry

searchPattern
String

Vzor hledání. Podporují se zástupné znaky s jedním znakem ("?") i víceznakové (*).

Návraty

String[]

Pole relativních cest k souborům v oboru izolovaného úložiště, které odpovídají searchPattern. Pole nulové délky určuje, že neexistují žádné soubory, které by odpovídaly.

Výjimky

searchPattern je null.

Izolované úložiště bylo odstraněno.

Izolované úložiště bylo odebráno.

Cesta k souboru určená nástrojem nebyla nalezena searchPattern .

Příklady

Následující příklad kódu ukazuje metodu GetFileNames . Úplný kontext tohoto příkladu najdete v přehledu IsolatedStorageFile .

array<String^>^dirNames = isoFile->GetDirectoryNames( "*" );
array<String^>^fileNames = isoFile->GetFileNames( "*" );

// List directories currently in this Isolated Storage.
if ( dirNames->Length > 0 )
{
   for ( int i = 0; i < dirNames->Length; ++i )
   {
      Console::WriteLine( "Directory Name: {0}", dirNames[ i ] );

   }
}


// List the files currently in this Isolated Storage.
// The list represents all users who have personal preferences stored for this application.
if ( fileNames->Length > 0 )
{
   for ( int i = 0; i < fileNames->Length; ++i )
   {
      Console::WriteLine( "File Name: {0}", fileNames[ i ] );

   }
}
    String[] dirNames = isoFile.GetDirectoryNames("*");
    String[] fileNames = isoFile.GetFileNames("Archive\\*");

    // Delete all the files currently in the Archive directory.

    if (fileNames.Length > 0)
    {
        for (int i = 0; i < fileNames.Length; ++i)
        {
            // Delete the files.
            isoFile.DeleteFile("Archive\\" + fileNames[i]);
        }
        // Confirm that no files remain.
        fileNames = isoFile.GetFileNames("Archive\\*");
    }

    if (dirNames.Length > 0)
    {
        for (int i = 0; i < dirNames.Length; ++i)
        {
            // Delete the Archive directory.
        }
    }
    dirNames = isoFile.GetDirectoryNames("*");
    isoFile.Remove();
}
catch (Exception e)
{
    Console.WriteLine(e.ToString());
}
Dim dirNames As String() = isoFile.GetDirectoryNames("*")
Dim fileNames As String() = isoFile.GetFileNames("*")
Dim name As String

' List directories currently in this Isolated Storage.
If dirNames.Length > 0 Then

    For Each name In dirNames
        Console.WriteLine("Directory Name: " & name)
    Next name
End If

' List the files currently in this Isolated Storage.
' The list represents all users who have personal preferences stored for this application.
If fileNames.Length > 0 Then

    For Each name In fileNames
        Console.WriteLine("File Name: " & name)
    Next name
End If

Poznámky

" searchPattern Project\Data*.txt" zobrazí všechny ".txt" soubory začínající na Data v adresáři projektu v oboru izolovaného úložiště. Úplný popis řetězců vzorů vyhledávání najdete v tématu System.IO.Directory.

Informace o tom, jak najít názvy adresářů, najdete v GetDirectoryNames metodě .

Příklad Postupy: Vyhledání existujících souborů a adresářů v izolovaném úložišti ukazuje použití GetFileNames metody .

Viz také

Platí pro