Network.DownloadFile メソッド

定義

指定したリモート ファイルをダウンロードし、指定した場所に保存します。

オーバーロード

名前 説明
DownloadFile(String, String)

指定したリモート ファイルをダウンロードし、指定した場所に保存します。

DownloadFile(Uri, String)

指定したリモート ファイルをダウンロードし、指定した場所に保存します。

DownloadFile(String, String, String, String)

指定したリモート ファイルをダウンロードし、指定した場所に保存します。

DownloadFile(Uri, String, String, String)

指定したリモート ファイルをダウンロードし、指定した場所に保存します。

DownloadFile(Uri, String, ICredentials, Boolean, Int32, Boolean)

指定したリモート ファイルをダウンロードし、指定した場所に保存します。

DownloadFile(String, String, String, String, Boolean, Int32, Boolean)

指定したリモート ファイルをダウンロードし、指定した場所に保存します。

DownloadFile(Uri, String, ICredentials, Boolean, Int32, Boolean, UICancelOption)

指定したリモート ファイルをダウンロードし、指定した場所に保存します。

DownloadFile(Uri, String, String, String, Boolean, Int32, Boolean)

指定したリモート ファイルをダウンロードし、指定した場所に保存します。

DownloadFile(String, String, String, String, Boolean, Int32, Boolean, UICancelOption)

指定したリモート ファイルをダウンロードし、指定した場所に保存します。

DownloadFile(Uri, String, String, String, Boolean, Int32, Boolean, UICancelOption)

指定したリモート ファイルをダウンロードし、指定した場所に保存します。

DownloadFile(String, String)

指定したリモート ファイルをダウンロードし、指定した場所に保存します。

public:
 void DownloadFile(System::String ^ address, System::String ^ destinationFileName);
public void DownloadFile(string address, string destinationFileName);
member this.DownloadFile : string * string -> unit
Public Sub DownloadFile (address As String, destinationFileName As String)

パラメーター

address
String

ダウンロードするファイルのパス (ファイル名とホスト アドレスを含む)。

destinationFileName
String

ダウンロードしたファイルのファイル名とパス。

例外

destinationFileName は末尾のスラッシュで終わります。

サーバーは、既定のタイムアウト (100 秒) 以内に応答しません。

ユーザーには、ネットワーク操作を実行するために必要なアクセス許可がありません。

要求はターゲット Web サーバーによって拒否されます。

この例では、http://www.cohowinery.com/downloadsからファイル WineList.txtをダウンロードし、C:\Documents and Settings\All Users\Documentsに保存します。

My.Computer.Network.DownloadFile(
  "http://www.cohowinery.com/downloads/WineList.txt", 
  "C:\Documents and Settings\All Users\Documents\WineList.txt")

この例では、http://www.cohowinery.com/downloadsからファイル WineList.txtをダウンロードし、500 ミリ秒のタイムアウト間隔を指定してC:\Documents and Settings\All Users\Documentsに保存します。

My.Computer.Network.DownloadFile(
  "http://www.cohowinery.com/downloads/", 
  "C:\Documents and Settings\All Users\Documents\WineList.txt", 
  "", "", False, 500, True)

注釈

コピー先のファイルが既に存在する場合、 DownloadFile メソッドは既存のファイルを上書きしません。 DownloadFile メソッドの他のオーバーロードのいずれかを使用して、既存のファイルの上書き、ユーザー資格情報の指定、または特定のタイムアウト値の指定を指示できます。

DownloadFile では、アプリケーションでネットワーク トレースを有効にすると、トレース情報が出力されます。 詳細については、「 ネットワーク トレースの有効化」を参照してください。

Note

DownloadFile メソッドは、省略可能な HTTP ヘッダーを送信しません。 オプションのユーザー エージェント ヘッダーがない場合、一部のサーバーから 500 (内部サーバー エラー) が返されることがあります。 省略可能なヘッダーを送信するには、 WebClient クラスを使用して要求を作成する必要があります。

次の表に、 My.Computer.Network.DownloadFile メソッドを含むタスクの例を示します。

ターゲット 参照先
ファイルをダウンロードする 方法: ファイルをダウンロードする

こちらもご覧ください

適用対象

DownloadFile(Uri, String)

指定したリモート ファイルをダウンロードし、指定した場所に保存します。

public:
 void DownloadFile(Uri ^ address, System::String ^ destinationFileName);
public void DownloadFile(Uri address, string destinationFileName);
member this.DownloadFile : Uri * string -> unit
Public Sub DownloadFile (address As Uri, destinationFileName As String)

パラメーター

address
Uri

ダウンロードするファイルのパス (ファイル名とホスト アドレスを含む)。

destinationFileName
String

ダウンロードしたファイルのファイル名とパス。

例外

destinationFileName は末尾のスラッシュで終わります。

サーバーは、既定のタイムアウト (100 秒) 以内に応答しません。

ユーザーには、ネットワーク操作を実行するために必要なアクセス許可がありません。

要求はターゲット Web サーバーによって拒否されます。

この例では、http://www.cohowinery.com/downloadsからファイル WineList.txtをダウンロードし、C:\Documents and Settings\All Users\Documentsに保存します。

My.Computer.Network.DownloadFile(
  "http://www.cohowinery.com/downloads/WineList.txt", 
  "C:\Documents and Settings\All Users\Documents\WineList.txt")

この例では、http://www.cohowinery.com/downloadsからファイル WineList.txtをダウンロードし、500 ミリ秒のタイムアウト間隔を指定してC:\Documents and Settings\All Users\Documentsに保存します。

My.Computer.Network.DownloadFile(
  "http://www.cohowinery.com/downloads/", 
  "C:\Documents and Settings\All Users\Documents\WineList.txt", 
  "", "", False, 500, True)

注釈

コピー先のファイルが既に存在する場合、 DownloadFile メソッドは既存のファイルを上書きしません。 DownloadFile メソッドの他のオーバーロードのいずれかを使用して、既存のファイルの上書き、ユーザー資格情報の指定、または特定のタイムアウト値の指定を指示できます。 DownloadFile では、アプリケーションでネットワーク トレースを有効にすると、トレース情報が出力されます。 詳細については、「 ネットワーク トレースの有効化」を参照してください。

Note

DownloadFile メソッドは、省略可能な HTTP ヘッダーを送信しません。 オプションのユーザー エージェント ヘッダーがない場合、一部のサーバーから 500 (内部サーバー エラー) が返されることがあります。 省略可能なヘッダーを送信するには、 WebClient クラスを使用して要求を作成する必要があります。

次の表に、 My.Computer.Network.DownloadFile メソッドを含むタスクの例を示します。

ターゲット 参照先
ファイルをダウンロードする 方法: ファイルをダウンロードする

こちらもご覧ください

適用対象

DownloadFile(String, String, String, String)

指定したリモート ファイルをダウンロードし、指定した場所に保存します。

public:
 void DownloadFile(System::String ^ address, System::String ^ destinationFileName, System::String ^ userName, System::String ^ password);
public void DownloadFile(string address, string destinationFileName, string userName, string password);
member this.DownloadFile : string * string * string * string -> unit
Public Sub DownloadFile (address As String, destinationFileName As String, userName As String, password As String)

パラメーター

address
String

ダウンロードするファイルのパス (ファイル名とホスト アドレスを含む)。

destinationFileName
String

ダウンロードしたファイルのファイル名とパス。

userName
String

認証するユーザー名。 既定値は空の文字列 "" です。

password
String

認証するパスワード。 既定値は空の文字列 "" です。

例外

destinationFileName は末尾のスラッシュで終わります。

サーバーは、既定のタイムアウト (100 秒) 以内に応答しません。

ユーザーには、ネットワーク操作を実行するために必要なアクセス許可がありません。

要求はターゲット Web サーバーによって拒否されます。

この例では、http://www.cohowinery.com/downloadsからファイル WineList.txtをダウンロードし、C:\Documents and Settings\All Users\Documentsに保存します。

My.Computer.Network.DownloadFile(
  "http://www.cohowinery.com/downloads/WineList.txt", 
  "C:\Documents and Settings\All Users\Documents\WineList.txt")

この例では、http://www.cohowinery.com/downloadsからファイル WineList.txtをダウンロードし、500 ミリ秒のタイムアウト間隔を指定してC:\Documents and Settings\All Users\Documentsに保存します。

My.Computer.Network.DownloadFile(
  "http://www.cohowinery.com/downloads/", 
  "C:\Documents and Settings\All Users\Documents\WineList.txt", 
  "", "", False, 500, True)

注釈

コピー先のファイルが既に存在する場合、 DownloadFile メソッドは既存のファイルを上書きしません。 DownloadFile メソッドの他のオーバーロードのいずれかを使用して、既存のファイルを上書きするか、特定のタイムアウト値を指定するように指示できます。

DownloadFile では、アプリケーションでネットワーク トレースを有効にすると、トレース情報が出力されます。 詳細については、「 ネットワーク トレースの有効化」を参照してください。

Note

DownloadFile メソッドは、省略可能な HTTP ヘッダーを送信しません。 オプションのユーザー エージェント ヘッダーがない場合、一部のサーバーから 500 (内部サーバー エラー) が返されることがあります。 省略可能なヘッダーを送信するには、 WebClient クラスを使用して要求を作成する必要があります。

Note

FTP プロトコルは、パスワードを含む情報をプレーン テキストで送信します。機密情報の送信には使用しないでください。

次の表に、 My.Computer.Network.DownloadFile メソッドを含むタスクの例を示します。

ターゲット 参照先
ファイルをダウンロードする 方法: ファイルをダウンロードする

こちらもご覧ください

適用対象

DownloadFile(Uri, String, String, String)

指定したリモート ファイルをダウンロードし、指定した場所に保存します。

public:
 void DownloadFile(Uri ^ address, System::String ^ destinationFileName, System::String ^ userName, System::String ^ password);
public void DownloadFile(Uri address, string destinationFileName, string userName, string password);
member this.DownloadFile : Uri * string * string * string -> unit
Public Sub DownloadFile (address As Uri, destinationFileName As String, userName As String, password As String)

パラメーター

address
Uri

ダウンロードするファイルのパス (ファイル名とホスト アドレスを含む)。

destinationFileName
String

ダウンロードしたファイルのファイル名とパス。

userName
String

認証するユーザー名。 既定値は空の文字列 "" です。

password
String

認証するパスワード。 既定値は空の文字列 "" です。

例外

destinationFileName は末尾のスラッシュで終わります。

サーバーは、既定のタイムアウト (100 秒) 以内に応答しません。

ユーザーには、ネットワーク操作を実行するために必要なアクセス許可がありません。

要求はターゲット Web サーバーによって拒否されます。

この例では、http://www.cohowinery.com/downloadsからファイル WineList.txtをダウンロードし、C:\Documents and Settings\All Users\Documentsに保存します。

My.Computer.Network.DownloadFile(
  "http://www.cohowinery.com/downloads/WineList.txt", 
  "C:\Documents and Settings\All Users\Documents\WineList.txt")

この例では、http://www.cohowinery.com/downloadsからファイル WineList.txtをダウンロードし、500 ミリ秒のタイムアウト間隔を指定してC:\Documents and Settings\All Users\Documentsに保存します。

My.Computer.Network.DownloadFile(
  "http://www.cohowinery.com/downloads/", 
  "C:\Documents and Settings\All Users\Documents\WineList.txt", 
  "", "", False, 500, True)

注釈

コピー先のファイルが既に存在する場合、 DownloadFile メソッドは既存のファイルを上書きしません。 DownloadFile メソッドの他のオーバーロードのいずれかを使用して、既存のファイルを上書きするか、特定のタイムアウト値を指定するように指示できます。

DownloadFile では、アプリケーションでネットワーク トレースを有効にすると、トレース情報が出力されます。 詳細については、「 ネットワーク トレースの有効化」を参照してください。

Note

DownloadFile メソッドは、省略可能な HTTP ヘッダーを送信しません。 オプションのユーザー エージェント ヘッダーがない場合、一部のサーバーから 500 (内部サーバー エラー) が返されることがあります。 省略可能なヘッダーを送信するには、 WebClient クラスを使用して要求を作成する必要があります。

Note

FTP プロトコルは、パスワードを含む情報をプレーン テキストで送信します。機密情報の送信には使用しないでください。

次の表に、 My.Computer.Network.DownloadFile メソッドを含むタスクの例を示します。

ターゲット 参照先
ファイルをダウンロードする 方法: ファイルをダウンロードする

こちらもご覧ください

適用対象

DownloadFile(Uri, String, ICredentials, Boolean, Int32, Boolean)

指定したリモート ファイルをダウンロードし、指定した場所に保存します。

public:
 void DownloadFile(Uri ^ address, System::String ^ destinationFileName, System::Net::ICredentials ^ networkCredentials, bool showUI, int connectionTimeout, bool overwrite);
public void DownloadFile(Uri address, string destinationFileName, System.Net.ICredentials networkCredentials, bool showUI, int connectionTimeout, bool overwrite);
member this.DownloadFile : Uri * string * System.Net.ICredentials * bool * int * bool -> unit
Public Sub DownloadFile (address As Uri, destinationFileName As String, networkCredentials As ICredentials, showUI As Boolean, connectionTimeout As Integer, overwrite As Boolean)

パラメーター

address
Uri

String または Uri。 ダウンロードするファイルのパス (ファイル名とホスト アドレスを含む)。

destinationFileName
String

String。 ダウンロードしたファイルのファイル名とパス。

networkCredentials
ICredentials

ICredentials。 指定する資格情報。

showUI
Boolean

True 操作の進行状況を表示する場合。それ以外の場合は False。 既定値は False です。

connectionTimeout
Int32

タイムアウト間隔 (ミリ秒単位)。 既定値は 100 秒です。

overwrite
Boolean

True 既存のファイルを上書きする場合。それ以外の場合は False。 既定値は False です。

例外

destinationFileName は末尾のスラッシュで終わります。

overwriteFalse に設定され、宛先ファイルが既に存在します。

サーバーは、指定された connectionTimeout内で応答しません。

ユーザーには、ネットワーク操作を実行するために必要なアクセス許可がありません。

要求はターゲット Web サーバーによって拒否されます。

この例では、http://www.cohowinery.com/downloadsからファイル WineList.txtをダウンロードし、C:\Documents and Settings\All Users\Documentsに保存します。

My.Computer.Network.DownloadFile(
  "http://www.cohowinery.com/downloads/WineList.txt", 
  "C:\Documents and Settings\All Users\Documents\WineList.txt")

この例では、http://www.cohowinery.com/downloadsからファイル WineList.txtをダウンロードし、500 ミリ秒のタイムアウト間隔を指定してC:\Documents and Settings\All Users\Documentsに保存します。

My.Computer.Network.DownloadFile(
  "http://www.cohowinery.com/downloads/", 
  "C:\Documents and Settings\All Users\Documents\WineList.txt", 
  "", "", False, 500, True)

注釈

showUITrueに設定されている場合は、操作の進行状況を示すダイアログ ボックスが表示されます。ダイアログ ボックスには、操作の取り消しに使用できる [キャンセル] ボタンが表示されます。 ダイアログ ボックスはモーダルではないため、プログラム内の他のウィンドウへのユーザー入力はブロックされません。

指定した connectionTimeout内でサーバーが応答しない場合、操作は取り消され、例外がスローされます。

DownloadFile では、アプリケーションでネットワーク トレースを有効にすると、トレース情報が出力されます。 詳細については、「 ネットワーク トレースの有効化」を参照してください。

Note

DownloadFile メソッドは、省略可能な HTTP ヘッダーを送信しません。 オプションのユーザー エージェント ヘッダーがない場合、一部のサーバーから 500 (内部サーバー エラー) が返されることがあります。 省略可能なヘッダーを送信するには、 WebClient クラスを使用して要求を作成する必要があります。

Note

FTP プロトコルは、パスワードを含む情報をプレーン テキストで送信します。機密情報の送信には使用しないでください。

次の表に、 My.Computer.Network.DownloadFile メソッドを含むタスクの例を示します。

ターゲット 参照先
ファイルをダウンロードする 方法: ファイルをダウンロードする

こちらもご覧ください

適用対象

DownloadFile(String, String, String, String, Boolean, Int32, Boolean)

指定したリモート ファイルをダウンロードし、指定した場所に保存します。

public:
 void DownloadFile(System::String ^ address, System::String ^ destinationFileName, System::String ^ userName, System::String ^ password, bool showUI, int connectionTimeout, bool overwrite);
public void DownloadFile(string address, string destinationFileName, string userName, string password, bool showUI, int connectionTimeout, bool overwrite);
member this.DownloadFile : string * string * string * string * bool * int * bool -> unit
Public Sub DownloadFile (address As String, destinationFileName As String, userName As String, password As String, showUI As Boolean, connectionTimeout As Integer, overwrite As Boolean)

パラメーター

address
String

ダウンロードするファイルのパス (ファイル名とホスト アドレスを含む)。

destinationFileName
String

ダウンロードしたファイルのファイル名とパス。

userName
String

認証するユーザー名。 既定値は空の文字列 "" です。

password
String

認証するパスワード。 既定値は空の文字列 "" です。

showUI
Boolean

True 操作の進行状況を表示する場合。それ以外の場合は False。 既定値は False です。

connectionTimeout
Int32

Int32。 タイムアウト間隔 (ミリ秒単位)。 既定値は 100 秒です。

overwrite
Boolean

True 既存のファイルを上書きする場合。それ以外の場合は False。 既定値は False です。

例外

destinationFileName は末尾のスラッシュで終わります。

overwriteFalse に設定され、宛先ファイルが既に存在します。

サーバーは、指定された connectionTimeout内で応答しません。

ユーザーには、ネットワーク操作を実行するために必要なアクセス許可がありません。

要求はターゲット Web サーバーによって拒否されます。

この例では、http://www.cohowinery.com/downloadsからファイル WineList.txtをダウンロードし、C:\Documents and Settings\All Users\Documentsに保存します。

My.Computer.Network.DownloadFile(
  "http://www.cohowinery.com/downloads/WineList.txt", 
  "C:\Documents and Settings\All Users\Documents\WineList.txt")

この例では、http://www.cohowinery.com/downloadsからファイル WineList.txtをダウンロードし、500 ミリ秒のタイムアウト間隔を指定してC:\Documents and Settings\All Users\Documentsに保存します。

My.Computer.Network.DownloadFile(
  "http://www.cohowinery.com/downloads/", 
  "C:\Documents and Settings\All Users\Documents\WineList.txt", 
  "", "", False, 500, True)

注釈

showUITrueに設定されている場合は、操作の進行状況を示すダイアログ ボックスが表示されます。ダイアログ ボックスには、操作の取り消しに使用できる [キャンセル] ボタンが表示されます。 ダイアログ ボックスはモーダルではないため、プログラム内の他のウィンドウへのユーザー入力はブロックされません。

指定した connectionTimeout内でサーバーが応答しない場合、操作は取り消され、例外がスローされます。

DownloadFile では、アプリケーションでネットワーク トレースを有効にすると、トレース情報が出力されます。 詳細については、「 ネットワーク トレースの有効化」を参照してください。

Note

DownloadFile メソッドは、省略可能な HTTP ヘッダーを送信しません。 オプションのユーザー エージェント ヘッダーがない場合、一部のサーバーから 500 (内部サーバー エラー) が返されることがあります。 省略可能なヘッダーを送信するには、 WebClient クラスを使用して要求を作成する必要があります。

Note

FTP プロトコルは、パスワードを含む情報をプレーン テキストで送信します。機密情報の送信には使用しないでください。

次の表に、 My.Computer.Network.DownloadFile メソッドを含むタスクの例を示します。

ターゲット 参照先
ファイルをダウンロードする 方法: ファイルをダウンロードする

こちらもご覧ください

適用対象

DownloadFile(Uri, String, ICredentials, Boolean, Int32, Boolean, UICancelOption)

指定したリモート ファイルをダウンロードし、指定した場所に保存します。

public:
 void DownloadFile(Uri ^ address, System::String ^ destinationFileName, System::Net::ICredentials ^ networkCredentials, bool showUI, int connectionTimeout, bool overwrite, Microsoft::VisualBasic::FileIO::UICancelOption onUserCancel);
public void DownloadFile(Uri address, string destinationFileName, System.Net.ICredentials networkCredentials, bool showUI, int connectionTimeout, bool overwrite, Microsoft.VisualBasic.FileIO.UICancelOption onUserCancel);
member this.DownloadFile : Uri * string * System.Net.ICredentials * bool * int * bool * Microsoft.VisualBasic.FileIO.UICancelOption -> unit
Public Sub DownloadFile (address As Uri, destinationFileName As String, networkCredentials As ICredentials, showUI As Boolean, connectionTimeout As Integer, overwrite As Boolean, onUserCancel As UICancelOption)

パラメーター

address
Uri

ダウンロードするファイルのパス (ファイル名とホスト アドレスを含む)。

destinationFileName
String

ダウンロードしたファイルのファイル名とパス。

networkCredentials
ICredentials

指定する資格情報。

showUI
Boolean

True 操作の進行状況を表示する場合。それ以外の場合は False。 既定値は False です。

connectionTimeout
Int32

タイムアウト間隔 (ミリ秒単位)。 既定値は 100 秒です。

overwrite
Boolean

True 既存のファイルを上書きする場合。それ以外の場合は False。 既定値は False です。

onUserCancel
UICancelOption

Trueに設定した結果として表示されるダイアログ ボックスでユーザーが [キャンセル] または [いいえ] をクリックしたときの動作showUI指定します。 既定値は ThrowException です。

例外

destinationFileName は末尾のスラッシュで終わります。

overwriteFalse に設定され、宛先ファイルが既に存在します。

サーバーは、指定された connectionTimeout内で応答しません。

ユーザーには、ネットワーク操作を実行するために必要なアクセス許可がありません。

要求はターゲット Web サーバーによって拒否されます。

この例では、http://www.cohowinery.com/downloadsからファイル WineList.txtをダウンロードし、C:\Documents and Settings\All Users\Documentsに保存します。

My.Computer.Network.DownloadFile(
  "http://www.cohowinery.com/downloads/WineList.txt", 
  "C:\Documents and Settings\All Users\Documents\WineList.txt")

この例では、http://www.cohowinery.com/downloadsからファイル WineList.txtをダウンロードし、500 ミリ秒のタイムアウト間隔を指定してC:\Documents and Settings\All Users\Documentsに保存します。

My.Computer.Network.DownloadFile(
  "http://www.cohowinery.com/downloads/", 
  "C:\Documents and Settings\All Users\Documents\WineList.txt", 
  "", "", False, 500, True)

注釈

showUITrueに設定されている場合は、操作の進行状況を示すダイアログ ボックスが表示されます。ダイアログ ボックスには、操作の取り消しに使用できる [キャンセル] ボタンが表示されます。 ダイアログ ボックスはモーダルではないため、プログラム内の他のウィンドウへのユーザー入力はブロックされません。

指定した connectionTimeout内でサーバーが応答しない場合、操作は取り消され、例外がスローされます。

DownloadFile では、アプリケーションでネットワーク トレースを有効にすると、トレース情報が出力されます。 詳細については、「 ネットワーク トレースの有効化」を参照してください。

Note

DownloadFile メソッドは、省略可能な HTTP ヘッダーを送信しません。 オプションのユーザー エージェント ヘッダーがない場合、一部のサーバーから 500 (内部サーバー エラー) が返されることがあります。 省略可能なヘッダーを送信するには、 WebClient クラスを使用して要求を作成する必要があります。

Note

FTP プロトコルは、パスワードを含む情報をプレーン テキストで送信します。機密情報の送信には使用しないでください。

次の表に、 My.Computer.Network.DownloadFile メソッドを含むタスクの例を示します。

ターゲット 参照先
ファイルをダウンロードする 方法: ファイルをダウンロードする

こちらもご覧ください

適用対象

DownloadFile(Uri, String, String, String, Boolean, Int32, Boolean)

指定したリモート ファイルをダウンロードし、指定した場所に保存します。

public:
 void DownloadFile(Uri ^ address, System::String ^ destinationFileName, System::String ^ userName, System::String ^ password, bool showUI, int connectionTimeout, bool overwrite);
public void DownloadFile(Uri address, string destinationFileName, string userName, string password, bool showUI, int connectionTimeout, bool overwrite);
member this.DownloadFile : Uri * string * string * string * bool * int * bool -> unit
Public Sub DownloadFile (address As Uri, destinationFileName As String, userName As String, password As String, showUI As Boolean, connectionTimeout As Integer, overwrite As Boolean)

パラメーター

address
Uri

ダウンロードするファイルのパス (ファイル名とホスト アドレスを含む)。

destinationFileName
String

ダウンロードしたファイルのファイル名とパス。

userName
String

認証するユーザー名。 既定値は空の文字列 "" です。

password
String

認証するパスワード。 既定値は空の文字列 "" です。

showUI
Boolean

True 操作の進行状況を表示する場合。それ以外の場合は False。 既定値は False です。

connectionTimeout
Int32

タイムアウト間隔 (ミリ秒単位)。 既定値は 100 秒です。

overwrite
Boolean

True 既存のファイルを上書きする場合。それ以外の場合は False。 既定値は False です。

例外

destinationFileName は末尾のスラッシュで終わります。

overwriteFalse に設定され、宛先ファイルが既に存在します。

サーバーは、指定された connectionTimeout内で応答しません。

ユーザーには、ネットワーク操作を実行するために必要なアクセス許可がありません。

要求はターゲット Web サーバーによって拒否されます。

この例では、http://www.cohowinery.com/downloadsからファイル WineList.txtをダウンロードし、C:\Documents and Settings\All Users\Documentsに保存します。

My.Computer.Network.DownloadFile(
  "http://www.cohowinery.com/downloads/WineList.txt", 
  "C:\Documents and Settings\All Users\Documents\WineList.txt")

この例では、http://www.cohowinery.com/downloadsからファイル WineList.txtをダウンロードし、500 ミリ秒のタイムアウト間隔を指定してC:\Documents and Settings\All Users\Documentsに保存します。

My.Computer.Network.DownloadFile(
  "http://www.cohowinery.com/downloads/", 
  "C:\Documents and Settings\All Users\Documents\WineList.txt", 
  "", "", False, 500, True)

注釈

showUITrueに設定されている場合は、操作の進行状況を示すダイアログ ボックスが表示されます。ダイアログ ボックスには、操作の取り消しに使用できる [キャンセル] ボタンが表示されます。 ダイアログ ボックスはモーダルではないため、プログラム内の他のウィンドウへのユーザー入力はブロックされません。

指定した connectionTimeout内でサーバーが応答しない場合、操作は取り消され、例外がスローされます。

DownloadFile では、アプリケーションでネットワーク トレースを有効にすると、トレース情報が出力されます。 詳細については、「 ネットワーク トレースの有効化」を参照してください。

Note

DownloadFile メソッドは、省略可能な HTTP ヘッダーを送信しません。 オプションのユーザー エージェント ヘッダーがない場合、一部のサーバーから 500 (内部サーバー エラー) が返されることがあります。 省略可能なヘッダーを送信するには、 WebClient クラスを使用して要求を作成する必要があります。

Note

FTP プロトコルは、パスワードを含む情報をプレーン テキストで送信します。機密情報の送信には使用しないでください。

次の表に、 My.Computer.Network.DownloadFile メソッドを含むタスクの例を示します。

ターゲット 参照先
ファイルをダウンロードする 方法: ファイルをダウンロードする

こちらもご覧ください

適用対象

DownloadFile(String, String, String, String, Boolean, Int32, Boolean, UICancelOption)

指定したリモート ファイルをダウンロードし、指定した場所に保存します。

public:
 void DownloadFile(System::String ^ address, System::String ^ destinationFileName, System::String ^ userName, System::String ^ password, bool showUI, int connectionTimeout, bool overwrite, Microsoft::VisualBasic::FileIO::UICancelOption onUserCancel);
public void DownloadFile(string address, string destinationFileName, string userName, string password, bool showUI, int connectionTimeout, bool overwrite, Microsoft.VisualBasic.FileIO.UICancelOption onUserCancel);
member this.DownloadFile : string * string * string * string * bool * int * bool * Microsoft.VisualBasic.FileIO.UICancelOption -> unit
Public Sub DownloadFile (address As String, destinationFileName As String, userName As String, password As String, showUI As Boolean, connectionTimeout As Integer, overwrite As Boolean, onUserCancel As UICancelOption)

パラメーター

address
String

ダウンロードするファイルのパス (ファイル名とホスト アドレスを含む)。

destinationFileName
String

ダウンロードしたファイルのファイル名とパス。

userName
String

認証するユーザー名。 既定値は空の文字列 "" です。

password
String

認証するパスワード。 既定値は空の文字列 "" です。

showUI
Boolean

True 操作の進行状況を表示する場合。それ以外の場合は False。 既定値は False です。

connectionTimeout
Int32

タイムアウト間隔 (ミリ秒単位)。 既定値は 100 秒です。

overwrite
Boolean

True 既存のファイルを上書きする場合。それ以外の場合は False。 既定値は False です。

onUserCancel
UICancelOption

Trueに設定した結果として表示されるダイアログ ボックスでユーザーが [キャンセル] または [いいえ] をクリックしたときの動作ShowUI指定します。 既定値は ThrowException です。

例外

destinationFileName は末尾のスラッシュで終わります。

overwriteFalse に設定され、宛先ファイルが既に存在します。

サーバーは、指定された connectionTimeout内で応答しません。

ユーザーには、ネットワーク操作を実行するために必要なアクセス許可がありません。

要求はターゲット Web サーバーによって拒否されます。

この例では、http://www.cohowinery.com/downloadsからファイル WineList.txtをダウンロードし、C:\Documents and Settings\All Users\Documentsに保存します。

My.Computer.Network.DownloadFile(
  "http://www.cohowinery.com/downloads/WineList.txt", 
  "C:\Documents and Settings\All Users\Documents\WineList.txt")

この例では、http://www.cohowinery.com/downloadsからファイル WineList.txtをダウンロードし、500 ミリ秒のタイムアウト間隔を指定してC:\Documents and Settings\All Users\Documentsに保存します。

My.Computer.Network.DownloadFile(
  "http://www.cohowinery.com/downloads/", 
  "C:\Documents and Settings\All Users\Documents\WineList.txt", 
  "", "", False, 500, True)

注釈

showUITrueに設定されている場合は、操作の進行状況を示すダイアログ ボックスが表示されます。ダイアログ ボックスには、操作の取り消しに使用できる [キャンセル] ボタンが表示されます。 ダイアログ ボックスはモーダルではないため、プログラム内の他のウィンドウへのユーザー入力はブロックされません。

指定した connectionTimeout内でサーバーが応答しない場合、操作は取り消され、例外がスローされます。

DownloadFile では、アプリケーションでネットワーク トレースを有効にすると、トレース情報が出力されます。 詳細については、「 ネットワーク トレースの有効化」を参照してください。

Note

DownloadFile メソッドは、省略可能な HTTP ヘッダーを送信しません。 オプションのユーザー エージェント ヘッダーがない場合、一部のサーバーから 500 (内部サーバー エラー) が返されることがあります。 省略可能なヘッダーを送信するには、 WebClient クラスを使用して要求を作成する必要があります。

Note

FTP プロトコルは、パスワードを含む情報をプレーン テキストで送信します。機密情報の送信には使用しないでください。

次の表に、 My.Computer.Network.DownloadFile メソッドを含むタスクの例を示します。

ターゲット 参照先
ファイルをダウンロードする 方法: ファイルをダウンロードする

こちらもご覧ください

適用対象

DownloadFile(Uri, String, String, String, Boolean, Int32, Boolean, UICancelOption)

指定したリモート ファイルをダウンロードし、指定した場所に保存します。

public:
 void DownloadFile(Uri ^ address, System::String ^ destinationFileName, System::String ^ userName, System::String ^ password, bool showUI, int connectionTimeout, bool overwrite, Microsoft::VisualBasic::FileIO::UICancelOption onUserCancel);
public void DownloadFile(Uri address, string destinationFileName, string userName, string password, bool showUI, int connectionTimeout, bool overwrite, Microsoft.VisualBasic.FileIO.UICancelOption onUserCancel);
member this.DownloadFile : Uri * string * string * string * bool * int * bool * Microsoft.VisualBasic.FileIO.UICancelOption -> unit
Public Sub DownloadFile (address As Uri, destinationFileName As String, userName As String, password As String, showUI As Boolean, connectionTimeout As Integer, overwrite As Boolean, onUserCancel As UICancelOption)

パラメーター

address
Uri

ダウンロードするファイルのパス (ファイル名とホスト アドレスを含む)。

destinationFileName
String

ダウンロードしたファイルのファイル名とパス。

userName
String

認証するユーザー名。 既定値は空の文字列 "" です。

password
String

認証するパスワード。 既定値は空の文字列 "" です。

showUI
Boolean

True 操作の進行状況を表示する場合。それ以外の場合は False。 既定値は False です。

connectionTimeout
Int32

タイムアウト間隔 (ミリ秒単位)。 既定値は 100 秒です。

overwrite
Boolean

True 既存のファイルを上書きする場合。それ以外の場合は False。 既定値は False です。

onUserCancel
UICancelOption

Trueに設定した結果として表示されるダイアログ ボックスでユーザーが [キャンセル] または [いいえ] をクリックしたときの動作ShowUI指定します。 既定値は ThrowException です。

例外

destinationFileName は末尾のスラッシュで終わります。

overwriteFalse に設定され、宛先ファイルが既に存在します。

サーバーは、指定された connectionTimeout内で応答しません。

ユーザーには、ネットワーク操作を実行するために必要なアクセス許可がありません。

要求はターゲット Web サーバーによって拒否されます。

この例では、http://www.cohowinery.com/downloadsからファイル WineList.txtをダウンロードし、C:\Documents and Settings\All Users\Documentsに保存します。

My.Computer.Network.DownloadFile(
  "http://www.cohowinery.com/downloads/WineList.txt", 
  "C:\Documents and Settings\All Users\Documents\WineList.txt")

この例では、http://www.cohowinery.com/downloadsからファイル WineList.txtをダウンロードし、500 ミリ秒のタイムアウト間隔を指定してC:\Documents and Settings\All Users\Documentsに保存します。

My.Computer.Network.DownloadFile(
  "http://www.cohowinery.com/downloads/", 
  "C:\Documents and Settings\All Users\Documents\WineList.txt", 
  "", "", False, 500, True)

注釈

showUITrueに設定されている場合は、操作の進行状況を示すダイアログ ボックスが表示されます。ダイアログ ボックスには、操作の取り消しに使用できる [キャンセル] ボタンが表示されます。 ダイアログ ボックスはモーダルではないため、プログラム内の他のウィンドウへのユーザー入力はブロックされません。

指定した connectionTimeout内でサーバーが応答しない場合、操作は取り消され、例外がスローされます。

DownloadFile では、アプリケーションでネットワーク トレースを有効にすると、トレース情報が出力されます。 詳細については、「 ネットワーク トレースの有効化」を参照してください。

Note

DownloadFile メソッドは、省略可能な HTTP ヘッダーを送信しません。 オプションのユーザー エージェント ヘッダーがない場合、一部のサーバーから 500 (内部サーバー エラー) が返されることがあります。 省略可能なヘッダーを送信するには、 WebClient クラスを使用して要求を作成する必要があります。

Note

FTP プロトコルは、パスワードを含む情報をプレーン テキストで送信します。機密情報の送信には使用しないでください。

次の表に、 My.Computer.Network.DownloadFile メソッドを含むタスクの例を示します。

ターゲット 参照先
ファイルをダウンロードする 方法: ファイルをダウンロードする

こちらもご覧ください

適用対象