1

I have a problem when copying an ".mdb" file (Microsoft Access) with the function "movefile".
I use a C++ visual studio 2010 program. Code :

strTxt1 = "g:\\temp\\toto.mdb";
strTxt2 = "g:\\temp\\tata.mdb";

if (!::MoveFile (strTxt1, strTxt2))
{
    CString strError;

    int iLastError = GetLastError();
    strError.Format(_T("Error  --> %d"), iLastError);

    AfxMessageBox(strError);
}  

Error :

enter image description here

I already check this post : C++ MoveFile giving ERROR_ACCESS_DENIED inconsistently for directory moves on Windows Server
I already try the MoveFileEx alternative but i have the same problem.

Remarques :
1- when i disable my antivirus, I don't have this problem
2- If I put a breakpoint at the start of the error block (CString strError;) and I manually replay the movefile instruction after a short wait (2 seconds) the movefile executes normally.

I'm sure it comes from my antivirus, but I haven't found a way to prove it "formally". I have already visited the log files of my antivirus, nothing is reported.

Landstalker
  • 1,368
  • 8
  • 9
  • In such case, you could always retry the operation for number of times with a Sleep statement. – EylM Jan 29 '20 at 14:14
  • maybe your pc is infected with a virus that hooks on MoveFile api? it's just a guess. i'm really not sure. – acegs Jan 29 '20 at 14:14
  • 1
    Yes, it's infected, but with an antivirus software. Sadly, these things are a known issue. Please report this as a bug to Trend, they need to be made aware that their software breaks other software! – Ulrich Eckhardt Jan 29 '20 at 14:18
  • @EylM yes, It is an alternative but I try to avoid solutions based on "sleep" – Landstalker Jan 29 '20 at 14:18
  • @acegs I try a full scan, my PC seems to be "OK" – Landstalker Jan 29 '20 at 14:19
  • 1
    In the past I had Trend Micro Titanium too, and I often had that kind of issues. It is overprotecting your computer. The only solution I got was to whitelist the trusted files... Until I removed Trend Micro Titanium from my computer :) – Fareanor Jan 29 '20 at 14:21
  • 1
    @UlrichEckhardt Yes, i will report this. – Landstalker Jan 29 '20 at 14:22
  • @Fareanor Thank you – Landstalker Jan 29 '20 at 14:23
  • Obvious question first: do you have access to G:\temp? Can you rename the file with Windows Explorer? – user253751 Jan 29 '20 at 14:23
  • @user253751 Of course and I have "admin" rights. This problem do not occur when i try "movefile" on **".txt"** files. – Landstalker Jan 29 '20 at 14:24
  • @user253751 OP said that it worked fine when disabling the antivirus protection so yes, he has the access. – Fareanor Jan 29 '20 at 14:26
  • are those file opened by database engine? Maybe some process keps this files in opened state in such case this error can be reported. – Marek R Jan 29 '20 at 14:28
  • @MarekR The files are not used by another program, are not open for editing, no program has a handle on my files. I checked everything with "processexplorer" – Landstalker Jan 29 '20 at 14:30
  • Maybe your antivirus detects an exe file with no signature, no admin rights to be executed, and seems to be not a legal software even though it's a simple exe. So other commenters are right that you a.) add your app to the whitelist of your antivirus for the time being and b.) report it to the company of the antivirus software you are using. – acegs Jan 30 '20 at 00:18
  • 1
    @acegs I have already tried to run my program in "administrator" mode and i had the same problem. Yes, i will add my program to the whitlist until the problem will be solved by the report services – Landstalker Jan 30 '20 at 08:47

0 Answers0