0

https://webgis.dme.qld.gov.au/webgis/webqmin/shapes/epm.tarからファイルをダウンロードして、webclient を使用して d:\ ドライブに保存しようとしています。"Client.DownloadFile" の直後に、クラス、構造体、またはインターフェイス メンバー宣言の無効なトークン '(' というエラーが表示されます。

C# を使うのはこれが初めてです。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Project1
{
    class Class1
    {
        WebClient Client = new WebClient ();
        Client.DownloadFile("https://webgis.dme.qld.gov.au/webgis/webqmin/shapes/epm.tar", @"d:\epm.tar");
     }
}
4

1 に答える 1

3

コードをメソッドに入れる必要があります。

namespace Project1
{
  class Class1
  {

    public void DownloadIt()
    {
        WebClient Client = new WebClient ();
        Client.DownloadFile("https://webgis.dme.qld.gov.au/webgis/webqmin/shapes/epm.tar",      @"d:\epm.tar");
    }
  }
}

それを使用するには、コンソール アプリまたは winform アプリからメソッドを呼び出すだけです。

Class1 c = new Class1();
c.DownloadIt();
于 2013-02-01T02:53:11.670 に答える