共用方式為


DiscoveryClientProtocol.ReadAll(String) 方法

定義

讀取包含已儲存探索文件對應的檔案,此文件填入 DocumentsReferences 屬性,並且在檔案中具有所參考的探索文件、XML 結構描述定義 (XSD) 結構描述和服務描述。

public:
 System::Web::Services::Discovery::DiscoveryClientResultCollection ^ ReadAll(System::String ^ topLevelFilename);
public System.Web.Services.Discovery.DiscoveryClientResultCollection ReadAll (string topLevelFilename);
member this.ReadAll : string -> System.Web.Services.Discovery.DiscoveryClientResultCollection
Public Function ReadAll (topLevelFilename As String) As DiscoveryClientResultCollection

參數

topLevelFilename
String

要讀取的檔案名稱,包含已儲存探索文件的對應。

傳回

DiscoveryClientResultCollection

DiscoveryClientResultCollection,包含在已儲存的探索文件對應檔案中找到的結果。 檔案格式為序列化成 XML 的 DiscoveryClientProtocol.DiscoveryClientResultsFile 類別;然而,您通常只會使用 WriteAll(String, String) 方法或 Disco.exe 建立檔案。

範例

下列程式碼範例是 Web Form,其會使用 ReadAll 方法來填 DataGrid 入現有探索對應檔中找到的檔和參考詳細資料。

 protected void Discover_Click(object Source, EventArgs e)
 {
  // Specify the URL to read the discovery results from.
  string outputDirectory = DiscoDir.Text;

      DiscoveryClientProtocol client = new DiscoveryClientProtocol();
  // Use default credentials to access the files containing the discovery results.
      client.Credentials = CredentialCache.DefaultCredentials;

      try {
        DiscoveryDocument doc;
    // Read in existing discovery results.
        DiscoveryClientResultCollection results = client.ReadAll(Path.Combine(DiscoDir.Text,"results.discomap"));
      }
      catch ( Exception e2) 
      {
        DiscoveryResultsGrid.Columns.Clear();
        Status.Text = e2.Message;
      }
  // If discovery documents existed in the supplied folder, display the results in a data grid.
      if (client.Documents.Count > 0)
      PopulateGrid(client);
}
Public Sub Discover_Click(Source As Object, e as EventArgs )
   ' Specify the URL to read the discovery results from.
   Dim outputDirectory As String = DiscoDir.Text

   Dim client as DiscoveryClientProtocol = new DiscoveryClientProtocol()
   ' Use default credentials to access files containing the previously saved discovery results.
   client.Credentials = CredentialCache.DefaultCredentials
   Try 
     Dim doc As DiscoveryDocument
  
    ' Read in existing discovery results.
     Dim results As DiscoveryClientResultCollection 
     results = client.ReadAll(Path.Combine(DiscoDir.Text,"results.discomap"))

   Catch e2 As Exception
       DiscoveryResultsGrid.Columns.Clear()
       Status.Text = e2.Message
   End Try

   ' If disocvery documents existed in the supplied folder, display the results in a data grid.
    If (client.Documents.Count > 0) Then
         ' Populate the data grid with the discovery results.
     PopulateGrid(client)
    End If
End Sub

備註

方法或Disco.exe可以建立 WriteAll 包含已儲存探索檔的對應檔案。

如果檔案不存在於目前目錄中,參數 topLevelFilename 必須包含完整路徑。

適用於