Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.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# 使用循环c注册图像#_C#_Image_File_Loops - Fatal编程技术网

C# 使用循环c注册图像#

C# 使用循环c注册图像#,c#,image,file,loops,C#,Image,File,Loops,我试过了 private void RegImages(int max) { string maxS = max.ToString(); bool t = false; do { max--; if (max <= 0) { t = true; } Image maxS

我试过了

private void RegImages(int max)
    {
        string maxS = max.ToString();
        bool t = false;
        do
        {
            max--;
            if (max <= 0)
            {
                t = true;
            }
            Image maxS = Image.FromFile(@"C:\Users\MahchinLizard\Desktop\assets\tiles\" +max +".png");
            Application.DoEvents();
        } while (t == true);
    }
private void RegImages(int max)
{
字符串maxS=max.ToString();
bool t=假;
做
{
马克斯;

如果(max我认为您应该使用以下循环:

        while (!t)
        {
            max--;
            if (max <= 0)
            {
                t = true;
            }
            Image maxS = Image.FromFile(@"C:\Users\MahchinLizard\Desktop\assets\tiles\" +max +".png");
            Application.DoEvents();
        }
while(!t)
{
马克斯;

如果(max@MahchinLizard,你是否在tiles文件夹中有所有名为“0.png”、“1.png”、…、“max-1.png”的图像?是的,我从“0.png”、“1.png”一直到我在RegImages中插入的最大值(int max)t是在函数中注册的布尔值,因此您可以看到所有内容。@MahchinLizard,很抱歉,我的意思是,当程序失败时,循环中的最大值是多少。然后发布此异常(这可能会提供更多帮助信息)