11-27-2015 04:32 AM
Hello all,
I'm using the DeleteFile () function to delete few files. The problem is when I call this function, i get this error :
Error -6 "Attempted to make an inoperable control the active control"
Here is the calling :
DeleteFile (tcCheminBase);
tcCheminBase = "C:\file.mdb" and the file exist for sure, I check it.
So I get these errors windows : This one when I debug the code
and this one when I Test the UIR
Can any one help me to solve that please ?
Best regards,
Solved! Go to Solution.
11-27-2015 04:46 AM - edited 11-27-2015 04:47 AM
DeleteFile does not return User Interface Library errors: it has a private set of error codes instead that you can see in the function help. Error -6 means Access Denied: you are likely to have problems working in the disk root since it is normally not allowed to create or delete files there unless you have administrative rights.
11-27-2015 04:51 AM
Hello,
I have admin rights.
Besides, I tryed to change the folder to "C:\Folder_Files\file.mdb" and I get the same error.
11-27-2015 05:09 AM - edited 11-27-2015 05:09 AM
I was able to delete a file in disk root:
r = DeleteFile ("c:\\test.txt");
I received no error and the file was actually deleted. It seems there's something particular in your system configuration.
Can you delete a file in the project folder?
int r;
char file[MAX_PATHNAME_LEN];
GetProjectDir (file);
MakePathname (file, "test.txt", file);
r = DeleteFile (file);
11-27-2015 06:35 AM
Yes. I tryed your code and I didn't get any problem.
Wierd ...
11-27-2015 06:35 AM
May be the file is used by another application ? How can I check that ?
11-29-2015 04:37 AM
I'm not aware of a way to catch whether the file is locked by another application. What you can do is to trap the error and handle it without stopping your app.
How are you building the pathname? Using the path returned from FIleSelectPopup or similar functions is the safest way, as well as building it up using MakePathname. Building the pathname with ordinary sprintf or similar commands can be problematic due to the backslash character that could be interpreted as an escape character.
12-08-2015 08:10 AM
Hello,
I'm using MakePathname so I'm not worring about the path string.
I solved the probem. In fact, I had an opened connection with the file in the folder that I want to delete, so when this file is used, you can't delete even manually in the OS.
I tracked the Open/Close connection with the data base, and I checked if all connections are closed.
Then when I callek the delete function, I didn't get any error.
Hope that this topic helps someone else.
Thank you.
Regards,