Directory locked by Google Drive, was: frmdir not removing directory

In my EOD auto-trading, I generally use CSV files written to my hard drive to store information about any trades I am in. I use Amibroker File Input/Output functions such as fmkdir and frmdir to create directories and write csv files in them. When the trade is exited, I use fdelete to first delete all files in the directory, then to delete the directory itself. May not be the best way to do things, but that was how I started.

It has worked for years, without too many problems. However, I'm now having a problem where the files are deleted fine but the folder/directory just won't delete. I can delete the directory fine manually in Windows Explorer, by selecting it and pressing delete, but using AB frmdir does not delete it. I confirm in Windows Explorer it is empty and there are no files in it. I'm wondering if anyone can offer some advice to point me in the right direction to troubleshoot. These are things I have already done:

  1. Since this problem happened at exactly the same time I updated from Google Backup & Sync to Google Drive (and this directory is in my Google Drive directory on my hard drive), I turn off the Sync for the entire folder. Still cannot delete directory using frmdir.

  2. Added a statement _TRACE( "Directory removed status is: " + NumToStr( remove_dir ) ); to attempt to troubleshoot, but it just gives me a 0 telling me directory not deleted, but I'm not sure if that adds any useful information since I know the directory is not deleting.

  3. Built a testing code:

create_dir = fmkdir( "D:\\Libraries\\Google Drive\\Trading Data\\Test" );
_TRACE( "Directory created status is: " + NumToStr( create_dir ) );

remove_dir = frmdir( "D:\\Libraries\\Google Drive\\Trading Data\\Test" );
_TRACE( "Directory removed status is: " + NumToStr( remove_dir ) );

Which creates the directory fine and deletes it fine. So within the same folder (that used to be on Google Drive sync - but has the Sync turned off now), using AB Input/Output functions, I can create the directory and then remove it, but I don't seem to be able to delete directories already there.

I'd greatly appreciate if anyone has any ideas on what might be causing my inability to delete, or could point me in the right direction of how I could troubleshoot further?

Thanks.

For further information, I have also tried viewing Properties in Windows Explorer and the security, sharing and general tabs have exactly the same properties for a folder than I can delete using frmdir when compared to a folder I cannot delete using frmdir.

Apologies as I guess this isn't an AB specific issue. I thought that users might be able to offer tips on how to debug to find out why the frmdir wasn't removing the directory, but my further work on the issue and troubleshooting has basically shown that as well as being unable to use fmdir from AB to remove directory I am also unable to use cmd prompt -> rd (for remove directory), I get the message "Access is denied".

My guess would be that the Google Drive for Desktop has somehow altered permissions or something so for some reason I do have access to delete the folder from within Windows 10, but not through other means such as AB or cmd prompt. After speaking several times to Google help, I've been unable to resolve the problem, but I have found a workaround.

Workaround

Once I turn off "mirror" or the syncing for the folder on Google Drive, it seems that any new folders don't have this Access Denied. I then just use Windows Explorer to move all the files within the old folders to new folders, delete the old folders and rename the new folders the exact same name as the deleted old folders. It is a pain of a workaround, but it does seem to work.

Instead of deleting the post, I'll leave it up with the workaround, in case by chance someone winds up with the same problem.

It has absolutely nothing to do with AmiBroker.
Every file and every directory that you are using with Google Drive or any OTHER program that LOCKS it can not be deleted by ANY means.
So it is not "workaround" to remove it from Google Drive. It is actual solution. Windows file system won't allow you to delete files/folders that are in-use by other process(es). I don't know with whom you talked @Google but apparently they are clueless about their own software.

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.