Compartilhar via


Método EnumDetachedDatabaseFiles

Enumera uma lista de arquivos de banco de dados desanexados.

Namespace:  Microsoft.SqlServer.Management.Smo
Assembly:  Microsoft.SqlServer.Smo (em Microsoft.SqlServer.Smo.dll)

Sintaxe

'Declaração
Public Function EnumDetachedDatabaseFiles ( _
    mdfName As String _
) As StringCollection
'Uso
Dim instance As Server
Dim mdfName As String
Dim returnValue As StringCollection

returnValue = instance.EnumDetachedDatabaseFiles(mdfName)
public StringCollection EnumDetachedDatabaseFiles(
    string mdfName
)
public:
StringCollection^ EnumDetachedDatabaseFiles(
    String^ mdfName
)
member EnumDetachedDatabaseFiles : 
        mdfName:string -> StringCollection 
public function EnumDetachedDatabaseFiles(
    mdfName : String
) : StringCollection

Parâmetros

Valor de retorno

Tipo: System.Collections.Specialized. . :: . .StringCollection
Um valor do objeto de sistema StringCollection que contém uma lista de nomes de arquivo de banco de dados desanexado.

Comentários

Use this method to obtain the names of all detached database (.mdf and .ndf) files on the instance of SQL Server. 

Exemplos

C#

Server srv = new Server("(local)");
StringCollection sc = srv.EnumDetachedDatabaseFiles("C:\\Program Files\\Microsoft SQL Server\\MSSQL10_50.MSSQLSERVER\\MSSQL\\DATA\\DetachedDatabase.mdf");
foreach (String s in sc)
{
   Console.WriteLine(s);
}

PowerShell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")

$sc = $srv.EnumDetachedDatabaseFiles("C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\DetachedDatabase.mdf")

Foreach ($s in $sc)
{
   Write-Host $s
}