Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.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
Delphi在使用FindFirst/FindNext搜索时将单引号加倍_Delphi_Path_Find - Fatal编程技术网

Delphi在使用FindFirst/FindNext搜索时将单引号加倍

Delphi在使用FindFirst/FindNext搜索时将单引号加倍,delphi,path,find,Delphi,Path,Find,我在Windows7上使用Delphi2010,在递归搜索目录时出现单引号加倍的问题 这是我搜索目录的代码 if FindFirst(aPath + '*', faDirectory, sr) = 0 then try repeat if (sr.Name <> '.') and (sr.Name <> '..') then if (sr.Attr and faDirectory) = faDirectory

我在Windows7上使用Delphi2010,在递归搜索目录时出现单引号加倍的问题

这是我搜索目录的代码

  if FindFirst(aPath + '*', faDirectory, sr) = 0 then
    try
      repeat
        if  (sr.Name <> '.') and (sr.Name <> '..') then
          if (sr.Attr and faDirectory) = faDirectory then
            SearchFolderEx(aPath + sr.Name + '\', aSearchMasks);

      until FindNext(sr) <> 0;
    finally
      FindClose(sr);
    end;
FindFirst/FindNext将单引号加倍

'New Folder''s'
TSearchRec中的FindData.cFileName如下所示

('N', 'e', 'w', ' ', 'F', 'o', 'l', 'd', 'e', 'r', '''', 's', #0, #0, ...)

问题出在哪里?我如何解决它?

这里没有问题,没有什么需要解决的。
是字符串分隔符,仅转义以表示为
。当调试器以字符串形式向您显示
'
时,这只是它表示单个引号字符的方式

此处的文档涉及此主题:

所以

是长度为1的字符串,其单个元素是引号符号

同样地

'New Folder''s'
是定义字符串的Delphi字符串文字

New Folder's

调试器使用与字符串文本相同的规则显示变量的内容。

+1。注意,在调试器中检查变量时,这只是一个显示问题,对实际代码的行为或结果没有影响。值得注意的是,该行为依赖于版本。D2007调试器将单个
'
字符显示为
'
,而在XE上则显示为
'''
(显然D2010也是如此)(ansi范围内无所谓)。唯一需要解决的问题是
文件夹的
名称(双关语)。
'New Folder''s'
New Folder's