共用方式為


FileWebResponse.ResponseUri 屬性

定義

取得提供回應的檔案系統資源 URI。

public:
 virtual property Uri ^ ResponseUri { Uri ^ get(); };
public override Uri ResponseUri { get; }
member this.ResponseUri : Uri
Public Overrides ReadOnly Property ResponseUri As Uri

屬性值

Uri

Uri,包含提供回應的檔案系統資源 URI。

範例

下列範例會使用 ResponseUri 來擷取提供回應之文件系統資源的 URI。

void GetPage( String^ url )
{
   try
   {
      Uri^ fileUrl = gcnew Uri( String::Concat( "file://", url ) );
      
      // Create a 'FileWebrequest' object with the specified Uri .
      FileWebRequest^ myFileWebRequest = (FileWebRequest^)( WebRequest::Create( fileUrl ) );
      
      // Send the 'fileWebRequest' and wait for response.
      FileWebResponse^ myFileWebResponse = (FileWebResponse^)( myFileWebRequest->GetResponse() );
      Console::WriteLine( "\nThe Uri of the file system resource that provided the response is :\n {0}\n\n", myFileWebResponse->ResponseUri );
      
      // Release resources of response object.
      myFileWebResponse->Close();
   }
   catch ( WebException^ e ) 
   {
      Console::WriteLine( "\r\nWebException thrown. The Reason for failure is : {0}", e->Status );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message );
   }
}
public static void GetPage (String url)
{
    try
    {
        Uri fileUrl = new Uri ("file://" + url);

        // Create a 'FileWebrequest' object with the specified Uri .
        FileWebRequest myFileWebRequest = (FileWebRequest)WebRequest.Create (fileUrl);

        // Send the 'fileWebRequest' and wait for response.
        FileWebResponse myFileWebResponse = (FileWebResponse)myFileWebRequest.GetResponse ();

        Console.WriteLine ("\nThe Uri of the file system resource that provided the response is :\n{0}\n\n", myFileWebResponse.ResponseUri);

        // Release resources of response object.
        myFileWebResponse.Close ();
    }
    catch (WebException e)
    {
        Console.WriteLine ("\r\nWebException thrown. The Reason for failure is : {0}", e.Status);
    }
    catch (Exception e)
    {
        Console.WriteLine ("\nThe following Exception was raised : {0}", e.Message);
    }
}
Public Shared Sub GetPage(ByVal url As [String])
    Try
        Dim fileUrl As New Uri("file://" + url)
        ' Create a 'FileWebrequest' object with the specified Uri. 
        Dim myFileWebRequest As FileWebRequest = CType(WebRequest.Create(fileUrl), FileWebRequest)
        ' Send the 'fileWebRequest' and wait for response.
        Dim myFileWebResponse As FileWebResponse = CType(myFileWebRequest.GetResponse(), FileWebResponse)
        Console.WriteLine("The Uri of the file system resource that provided the response is : {0}", myFileWebResponse.ResponseUri)
        myFileWebResponse.Close()

    Catch e As WebException
        Console.WriteLine(ControlChars.Lf + ControlChars.Cr + "The Reason for failure is : {0}", e.Status)
    Catch e As Exception
        Console.WriteLine(ControlChars.Cr + "The following exception was raised : {0}", e.Message)
    End Try

備註

屬性 ResponseUri 包含提供回應之文件系統資源的 URI。 這一律是要求的文件系統資源。

適用於