開発環境 |
Microsoft Visual C++ 2010 Express (SP1) |
実行環境 |
Microsoft Windows XP Home Edition (SP3) |
プロジェクトの種類 |
空の CLR プロジェクト |
プロジェクト名 |
clrdlfile |
参考
clrdlfile.cpp
// .NET参照
#using <System.dll>
// 名前空間
using namespace System;
using namespace System::IO;
using namespace System::Net;
int main()
{
WebClient^ wc = gcnew WebClient;
while (true) {
try {
Console::Write(L"URL(Ctrl+Zで終了)>");
String^ address = Console::ReadLine();
if (address == nullptr) {
break;
}
String^ fileName = Path::GetFileName(address);
if (File::Exists(fileName)) {
Console::Write(L"上書きしますか(y/n)>");
String^ s = Console::ReadLine();
if (s != L"y") {
continue;
}
}
wc->DownloadFile(address, fileName);
}
catch (Exception^ e) {
Console::WriteLine(e->Message);
}
}
return 0;
}
最終更新:2012年09月29日 20:57