C#中的downloadstring问题 [英] Problems with downloadstring in C#

查看:174
本文介绍了C#中的downloadstring问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我不明白为什么这会告诉我有更新可用。

DownloadString函数是否会永久保存结果,这样如果再次执行programm,结果仍然是相同的即使答案已经改变了?如果是,只需回复是。

如果没有,请帮助我!



 var Webpagestring01 = string.Empty ; 
using(var web = new System.Net.WebClient())
Webpagestring01 = web.DownloadString(https://www.dropbox.com/s/yqig5di1smlkjkl/update.txt?dl=0 );

if(Webpagestring01.Contains(2.0.0))
{
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine(Update Found!);
Console.WriteLine();
Console.ResetColor();
Console.WriteLine(----------------------------------------- -------------------------------------------------- -----------------------------);
Console.WriteLine(如果要继续使用菜单,请按1安装更新或按2);
Console.WriteLine();
Console.WriteLine(----------------------------------------- -------------------------------------------------- -----------------------------);
int answer06 = Convert.ToInt32(Console.ReadLine());
if(answer06 == 1)
{
Process.Start(https://www.dropbox.com/sh/6gx6zf2lpy1u4xj/AAAEF7wgUrxYGX9v8PKvEmXna?dl=1);
}
否则if(answer06 == 2)
{
for(int i = 1; i< = 35; i ++)
{
Console.WriteLine();
}
转到菜单;
}
}





我的尝试:



我试图通过将Webpagestring的名称更改为Webpagestring01来解决问题

解决方案

如果加载字符串并保存它是一个文件,你会看到它是一个完整的网页,以及使其工作所需的Javascript。

它包含以下行:

 return {waitSeconds:30,map:{modules / shims / react:{__ real_external / react:external / react-15.3.1-prod,external / react: external / react-15.3.1-prod},external / jquery_security_patch_bundle:{jquery:jquery,__ real_jquery:jquery},external / react-redux-3.1.0:{ redux:external / redux-3.6.0},*:{external / react-dnd-scrollzone:external / react-dnd-scrollzone-3.0.0,external / react-dnd :external / react-dnd-2.1.4,external / tslib:tslib,langpack:javascript / langpack / en,external / immutable:exter nal / immutable-3,external / redux-thunk:external / redux-thunk-2.1.0,external / react-dom / server:external / react-dom / server-15.3.1- prod,external / sjcl:external / sjcl-1.0.3,__ real_jquery:jquery,external / videojs / video:external / videojs / video-5.10.7,external /反应:modules / shims / react,external / react-redux:external / react-redux-3.1.0,__ real_external / rsvp:external / rsvp,external / rsvp: modules / shims / es6-promise,external / react-router:external / react-router-2.0.0,

其中包含您要搜索的文本: 2.0.0

文档中还有其他几个字符串实例。

猜测,它不是你想要的页面/文档,也不是你的搜索字符串过于简单并且误报了误报。

但是在我们帮助您解决问题之前,我们需要更多地了解您正在尝试做什么以及您希望得到什么!


So I dont quite get why this shows me that there is an update availible.
Does the DownloadString function save the result permanentely so that if you execute the programm again the result will still be the same even if the answer has changed? If yes just reply with a yes.
If no please help me!

var Webpagestring01 = string.Empty;
            using (var web = new System.Net.WebClient())
                Webpagestring01 = web.DownloadString("https://www.dropbox.com/s/yqig5di1smlkjkl/update.txt?dl=0");

            if (Webpagestring01.Contains("2.0.0"))
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("                                                  Update Found!");
                Console.WriteLine();
                Console.ResetColor();
                Console.WriteLine("------------------------------------------------------------------------------------------------------------------------");
                Console.WriteLine("Press 1 to install the update or press 2 if you want to continue to the Menu");
                Console.WriteLine();
                Console.WriteLine("------------------------------------------------------------------------------------------------------------------------");
                int answer06 = Convert.ToInt32(Console.ReadLine());
                if (answer06 == 1)
                {
                    Process.Start("https://www.dropbox.com/sh/6gx6zf2lpy1u4xj/AAAEF7wgUrxYGX9v8PKvEmXna?dl=1");
                }
                else if (answer06 == 2)
                {
                    for (int i = 1; i <= 35; i++)
                    {
                        Console.WriteLine();
                    }
                    goto Menu;
                }
            }



What I have tried:

I tried to fix the problem by changing the names of the Webpagestring to Webpagestring01

解决方案

If you load the string and save it to a file, you'll see that it is a complete webpage, together with the Javascript necessary to make it work.
And it contains the line:

return {"waitSeconds": 30, "map": {"modules/shims/react": {"__real_external/react": "external/react-15.3.1-prod", "external/react": "external/react-15.3.1-prod"}, "external/jquery_security_patch_bundle": {"jquery": "jquery", "__real_jquery": "jquery"}, "external/react-redux-3.1.0": {"redux": "external/redux-3.6.0"}, "*": {"external/react-dnd-scrollzone": "external/react-dnd-scrollzone-3.0.0", "external/react-dnd": "external/react-dnd-2.1.4", "external/tslib": "tslib", "langpack": "javascript/langpack/en", "external/immutable": "external/immutable-3", "external/redux-thunk": "external/redux-thunk-2.1.0", "external/react-dom/server": "external/react-dom/server-15.3.1-prod", "external/sjcl": "external/sjcl-1.0.3", "__real_jquery": "jquery", "external/videojs/video": "external/videojs/video-5.10.7", "external/react": "modules/shims/react", "external/react-redux": "external/react-redux-3.1.0", "__real_external/rsvp": "external/rsvp", "external/rsvp": "modules/shims/es6-promise", "external/react-router": "external/react-router-2.0.0",

Which contains the text you are searching for: "2.0.0"
There are several other instances of that string in the document.
At a guess, either it's not the page / document you want, or your search string is too simple and catching a false positive.
But we'd need to know a lot more about exactly what you are trying to do and what you expect to get before we could help you fix the problem!


这篇关于C#中的downloadstring问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆