【发布时间】:2014-08-16 00:15:11
【问题描述】:
我是 C#/WPF 编程的新手,如果某个页面的源代码发生更改,我会尝试自动更新源代码的本地副本。有没有办法每隔一天检查一次源代码,而我不必手动执行差异?
获取我拥有的网站的源代码
Private bool getSourceCode(string UserInputSub)
{
//insert error catching..
using (WebClient webClient = new WebClient()) //Get source code of page.. user //enters URL
{
string s = webClient.DownloadString(UserInputSub);
string fixedString = s.Replace("\n", "\r\n");
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string FilePath = desktopPath + "\\SourceCode.txt";
System.IO.StreamWriter wr = new System.IO.StreamWriter(@FilePath);
wr.Write(fixedString);//writes to script
wr.Close();
}
return true;
}
这仅在程序运行时运行。我想要它,这样用户就没有运行程序来更新它产生的 txt。
【问题讨论】: