Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用Downloadfile将图像保存到特定文件夹中 用于(int counter=0;counter它是如何失败的?您是否检查了jj的值以确保您提取的URL是有效的?代码看起来有点粗略。您是否有足够的权限保存到该文件夹?您是否可以将该值发布到变量“t_C#_Webclient - Fatal编程技术网

C# 如何使用Downloadfile将图像保存到特定文件夹中 用于(int counter=0;counter它是如何失败的?您是否检查了jj的值以确保您提取的URL是有效的?代码看起来有点粗略。您是否有足够的权限保存到该文件夹?您是否可以将该值发布到变量“t

C# 如何使用Downloadfile将图像保存到特定文件夹中 用于(int counter=0;counter它是如何失败的?您是否检查了jj的值以确保您提取的URL是有效的?代码看起来有点粗略。您是否有足够的权限保存到该文件夹?您是否可以将该值发布到变量“t,c#,webclient,C#,Webclient,如何使用Downloadfile将图像保存到特定文件夹中 用于(int counter=0;counter它是如何失败的?您是否检查了jj的值以确保您提取的URL是有效的?代码看起来有点粗略。您是否有足够的权限保存到该文件夹?您是否可以将该值发布到变量“temparray”…?URL是有效的,不,我想我可以将其保存到任何地方。但是我希望在桌面或我的文档上执行此操作。但问题是,我真的不知道如何将图像存储在任何位置,并且当前它保存在我的visual studio项目文件夹的bin文件夹中 for (

如何使用Downloadfile将图像保存到特定文件夹中
用于(int counter=0;counter它是如何失败的?您是否检查了
jj
的值以确保您提取的URL是有效的?代码看起来有点粗略。您是否有足够的权限保存到该文件夹?您是否可以将该值发布到变量“temparray”…?URL是有效的,不,我想我可以将其保存到任何地方。但是我希望在桌面或我的文档上执行此操作。但问题是,我真的不知道如何将图像存储在任何位置,并且当前它保存在我的visual studio项目文件夹的bin文件夹中
for (int counter = 0; counter <= temparray.Length - 1; counter = counter + 1)
{
    if ((counter < temparray.Length + 2) && (temparray[counter] == "><img") &&    (temparray[counter + 1] == "id='header-img'"))
    {
        string j = temparray[counter + 2];

        int startIndex = j.IndexOf('"') + 1;

        int length = j.IndexOf('"', startIndex) - startIndex;

        string jj = (j.Substring(startIndex, length));

        client.DownloadFile(jj, @"C:\image.png");
    }
}