SoundPlayer.SoundLocation 屬性

定義

取得或設定要載入之 .wav 檔的檔案路徑或 URL。

public:
 property System::String ^ SoundLocation { System::String ^ get(); void set(System::String ^ value); };
public string SoundLocation { get; set; }
member this.SoundLocation : string with get, set
Public Property SoundLocation As String

屬性值

要由其載入 .wav 檔的檔案路徑或 URL,如果沒有檔案路徑,則是 Empty。 預設為 Empty

範例

下列程式代碼範例示範如何使用 SoundLocation 屬性,將.wav檔案來源指派給 類別的 SoundPlayer 實例。 此程式代碼範例是針對 類別提供的較大範例的 SoundPlayer 一部分。

try
{
   
   // Assign the selected file's path to 
   // the SoundPlayer object.  
   player->SoundLocation = filepathTextbox->Text;
   
   // Load the .wav file.
   player->Load();
}
catch ( Exception^ ex ) 
{
   ReportStatus( ex->Message );
}
try
{
    // Assign the selected file's path to 
    // the SoundPlayer object.  
    player.SoundLocation = filepathTextbox.Text;

    // Load the .wav file.
    player.Load();
}
catch (Exception ex)
{
    ReportStatus(ex.Message);
}
Try
    ' Assign the selected file's path to the SoundPlayer object.
    player.SoundLocation = filepathTextbox.Text

    ' Load the .wav file.
    player.Load()
Catch ex As Exception
    ReportStatus(ex.Message)
End Try

備註

當 屬性設定為 時,Stream這個屬性會設定String.EmptyStream

適用於

另請參閱