【发布时间】:2014-02-27 09:07:19
【问题描述】:
代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Net;
namespace Battlefield_Servers_Ping
{
public partial class Form1 : Form
{
private string appDirectory;
private string htmlFilesDirectory;
private string localFilename;
private string mainurl;
private string[] serversip;
public Form1()
{
InitializeComponent();
appDirectory = Path.GetDirectoryName(Application.LocalUserAppDataPath);
htmlFilesDirectory = "HtmlFilesDirectory";
htmlFilesDirectory = Path.Combine(appDirectory, htmlFilesDirectory);
Directory.CreateDirectory(htmlFilesDirectory + "\\Tests");
mainurl = "http://www.game-monitor.com/search.php?game=bfbc2&&num=";
using (WebClient client = new WebClient())
{
for (int i = 10; i <= 100; i += 10)
{
client.DownloadFile(mainurl + i, htmlFilesDirectory + "\\Tests\\" + i + ".html");
}
}
}
}
}
最后我在硬盘上有 10 个 html 文件,每个文件是 1kb,我看到里面:
[拒绝访问#2]
将它们在硬盘上的文件保存在我想要的目录中不是问题。网站有问题吗?
变量 htmlFilesDirectory 是:
C:\\Users\\bout0_000\\AppData\\Local\\Tests\\Tests\\HtmlFilesDirectory
网页来源为:
http://www.game-monitor.com/search.php?game=bfbc2&&num=10
如果我在此页面的浏览器 chrome 中的空白处进行保存,因为我可以保存 html 文件没有问题。并且稍后编辑它。 当我保存为文件名时:
Battlefield Bad Company 2 Servers Server Player Search Game-Monitor.com Server Search, Monitoring, Stats and more
但在我的程序中,我将它保存为 diffrenet。地址不一样。
【问题讨论】:
-
您以什么权限运行您的应用程序?管理员?
-
爸爸没有。以管理员身份尝试?
-
现在作为管理员尝试过同样的事情。不工作。
-
您将文件保存在哪里?您使用的是什么操作系统版本?
-
我将用详细信息编辑我的问题。