0

我搜索了论坛,但找不到有效的解决方案。这是问题所在:

  1. 我的 apache 根文件夹中有一个名为“encoding hello#.zip”的文件。

  2. 我正在使用以下代码通过 C# webclient.downloadfile 下载它:

    WebClient check = new WebClient();
    // check.Encoding = System.Text.Encoding.UTF8;
    
    string filename = "encoding hello#.ppt";
    filename = HttpUtility.UrlEncode(filename);
    check.DownloadFile("http://server/"+filename, "test");
    
  3. Apache 在日志文件中显示以下内容:

"GET /encoding+hello%23.ppt HTTP/1.1" 404 282 "-" "-"

这意味着它无法找到该文件。当然,会抛出 404 not found 异常。如果我不使用 URLEncode 请求将根本不包含 # 符号:

GET /encoding%20hello HTTP/1.1" 404 276 "-" "-"

我怎样才能下载这个文件?:/

4

0 回答 0