LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

[CVI2013] DeleteFile() error

Solved!
Go to solution

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 

Error_DeleteFile.png

 

and this one when I Test the UIR

Error_DeleteFile2.png

 

Can any one help me to solve that please ? 

 

Best regards, 

0 Kudos
Message 1 of 8
(5,183 Views)

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 8
(5,180 Views)

Hello,

 

I have admin rights. 

Besides, I tryed to change the folder to "C:\Folder_Files\file.mdb" and I get the same error. 

0 Kudos
Message 3 of 8
(5,177 Views)

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);

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 8
(5,175 Views)

Yes. I tryed your code and I didn't get any problem. 

 

Wierd ... 

0 Kudos
Message 5 of 8
(5,168 Views)

May be the file is used by another application ? How can I check that ? 

 

0 Kudos
Message 6 of 8
(5,167 Views)

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 7 of 8
(5,144 Views)
Solution
Accepted by topic author HoussamAz

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, 

0 Kudos
Message 8 of 8
(5,043 Views)