有可能在这里解决问题。 [英] Is it possible to fix the problem here.

查看:68
本文介绍了有可能在这里解决问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮助我使用下面的代码..它从编辑框中获取路径(例如,..c:\ users和list files。问题是当我按下按钮返回目录时...它不会列出所有文件。只需一个目录或一个文件



Can someone help me with this code below..It takes a path from a edit box(eg..c:\users and list files. The problem is when I press a button to go back a directory...it will not list all the files..just one directory or one file

void CAlDlg::OnButton1()
{
    m_b.ResetContent();

    UpdateData(true);
    CString left = m_o;
    UpdateData(false);
    CFileFind OneFile;
    CString FileName, DirName;
    BOOL BeWorking;

    int i = left.GetLength();

    for(int j = 0; j<i; j++)>
    {
        if (left[j] == '\\')
        {
            j++;
        }
    }

    CString howlong = left;
    UpdateData(true);

    CString gone = m_o;
    UpdateData(false);
    CString ocean = howlong + "*.*";

    BeWorking = OneFile.FindFile (ocean);

    while (BeWorking)
    {
        BeWorking = OneFile.FindNextFile () ;

        if(OneFile.IsDots()) continue;

        m_b.AddString(OneFile.GetFileName ());

        GetDlgItem(IDC_EDIT3)->SetWindowText(OneFile.GetRoot());
    }
    OneFile.Close ();
}

推荐答案

我会在线上设置一个断点

I would set a breakpoint on the line
BeWorking = OneFile.FindFile (ocean);



查看过滤器表达式的值( ocean )。我会假设问题就在那里。



作为一般评论:此代码是转储。你有没有看过它?例如,循环


And look at the value of your filter expression (ocean). I would assume the problem is there.

As a general remark: This code is a dump. Haven't you taken a look at it at all? For example, the loop

for(int j = 0; j<i;>
{
    if (left[j] == '\\')
    {
        j++;
    }
}



根本不做任何事情。这实际上可能是问题的一部分,因为在行中


does not do anything at all. That might in fact be part of the problem, because in line

CString ocean = howlong + "*.*";



你只需附加*。*。如果包含多长时间c:\ users \ abc怎么办?过滤器将是c:\users \abc *。*,这可能确实只返回一个文件的结果甚至更少。



变量已消失已设置但从未使用。我首先清理此代码,然后使用调试器逐步完成。


you simply append "*.*". What if howlong contained "c:\users\abc"? The filter would be "c:\users\abc*.*" and that might indeed only return a result of one file or even less.

The variable gone is set but never used. I would first clean this code up and then step through it with a debugger.


这篇关于有可能在这里解决问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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