重要なお知らせ

「教えて! goo」は2025年9月17日(水)をもちまして、サービスを終了いたします。詳細はこちら>

電子書籍の厳選無料作品が豊富!

ファイル及びディクレトリを削除する関数を作成しているのですが、
再帰した時に、FindFileでディレクトリが取得できなくなってしまいます。
エラー情報を取得すると、Error12110が出ていました。

12110 ERROR_FTP_TRANSFER_IN_PROGRESS
The requested operation cannot be made on the FTP session
handle because an operation is already in progress.

以下、ソースもつけます。
ご指摘いただければうれしいです。
よろしくお願いします。


try
{
CFtpFileFindfinder (m_ftpConP);
BOOLbWorking = FALSE;
CStringstrFilePath;

if ((bWorking = finder.FindFile(pIstrFilePath + "/*")) != 0)
{
while( bWorking != 0 )
{
bWorking = finder.FindNextFile();
if( finder.IsDots() != 0 ) continue;

strFilePath = pIstrFilePath + "/";
strFilePath += finder.GetFileName();
if( finder.IsDirectory() != 0 )
{
intRet = Remove( strFilePath );
}
else
{ // ファイル
if(m_ftpConP->Remove(strFilePath) == 0)
{
intRet = -1;
}
}
}
finder.Close();
if (!m_ftpConP->RemoveDirectory(pIstrFilePath))
{
intRet = -1;
}
}
}
catch (CInternetException* pEx)
{
TCHAR sz[1024];
pEx->GetErrorMessage(sz, 1024);
AfxMessageBox(sz);
pEx->Delete();
}

A 回答 (1件)

こちらのページによりますと、



http://homepage2.nifty.com/c_lang/sdk3/sdk_218.htm
>FtpFindFirstFile関数はFTPセッションで一度だけ使うことができると書かれています

なので、再帰で FtpFindFirstFile を呼んではいけないことになります。

例えば、再帰を呼ぶ前に finder を解放、戻ってきたらまた finder を作成、というふうにするとかですかね。
    • good
    • 0
この回答へのお礼

ありがとうございました。

再帰してはいけないんですね。

別の方法でやってみます。

お礼日時:2011/02/17 14:04

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!