LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create folder error 8 after deletion

Solved!
Go to solution

I have a weird error that I can't explain.

I have a folder \Support that will contain other files/folder inside.

I need to perform an unpdate, with this simple and straighforward algorithm:

1) Delete the hierarchy

2) Create a new \Support empty folder (and later copy fresh files/folder)

 

So I first call the "Check if file/folder exist" and :

1) If "exist? == no" --> Create Folder.vi  ---> this works OK

2) If "exist? == yes" --> Delete.vi with EntireHierarchy=True --> then Create Folder.vi ---> This gives me error 8.

 

Debugging shows that the Delete.vi has performed OK, so the folder is not present in file system, so why on earth should I have permission error on a non-existent folder? Why Create folder doesn't work after its deletion?

 

this is the diagram that gives error on the Create Folder. The error in before Create is "no error", it's OK.

 

Clipboard01.jpg

 

Any help appreciated

thanks

0 Kudos
Message 1 of 7
(3,521 Views)
Solution
Accepted by topic author Ironman_

Hi Ironman,

 

does it help to put a wait between Delete and CreateFolder? (Delay may depend on folder/hierarchy size!)

 

Just a guess:

- Delete tells Windows to delete a folder and all it's content. Then that Delete call returns with an "ok" message - but Windows is just starting with the file deletion.

- Now you immediatly tell Windows to create a folder - and you get an error message in return…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 7
(3,517 Views)

that is strange indeed. and in my quick test here with labview 2016 did not occur.

 

a few questions come to mind, how did you create the initial \support dir? by hand or through labview?

could it be that you don't have create rights in the base directory?

is the hierarchy very large so that the delete operation might take longer than the execution of the node?

(i don't know how labview+windows handle file system manipulation, but it might be that labview offloads the task to the os somehow, and it just isn't ready when the 'create folder" vi is executed. but i think it is unlikely)


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
Message 3 of 7
(3,505 Views)

Damn....

 

the correct way is to add a wait() ....

 

So to recap for the forum:

Windows 10 1803, LV2015, SSD 256GB Crucial M4.

Hierarchy of files trivial in size (about 30 files and 12 folders, max depth 2), but error happens even with 1 file inside \support

 

1) without wait I always have error on creator after the delete.

2) I noticed that if I put a "check if folder exist" between delete and create..... the folder still exists!!! So I guess LV (or windows) does this async, do the VI exit with "ok", but the SSD controller (o whatever) doesn't do this synchronous.

3) With wait(100) I have no error with 1 file in \support, but "Generic I/O error" with all the files (30 files and 12 folder)

4) With wait(1000) I have never and error.

 

At this point.... How can I force a SYNCHRONOUS delete??

 

Maybe this is a better version:

Clipboard01.jpg

Message 4 of 7
(3,492 Views)

Hi Ironman,

 

you might try to issue a rmdir command with SysExec (and wait for completion)…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 7
(3,483 Views)

found an interesting discussion

 

https://stackoverflow.com/questions/34981143/is-directory-delete-create-synchronous

 

I think it's related, the same "problem" happens also in .NET. But I don't know what is done inside Delete.vi (it's a buildt-in block).

 

I had windows explorer open on that folder (or parent) to see the modifications in real time, so maybe I was opening an handle (from OS perspective). Anyway an immediate subsequent operation can cause errors

0 Kudos
Message 6 of 7
(3,460 Views)

@GerdW wrote:

Hi Ironman,

 

you might try to issue a rmdir command with SysExec (and wait for completion)…


I like this idea.  I guess you could also poll the "Check if File Exists" by looping on it and exiting when it's no longer there, if you insist on staying "pure" LabVIEW.

 

I believe that the problem is with file caching.  Probably if you somehow managed to turn off ALL caching to that drive - between the OS and the hard drive, there are so many different levels of caching, it's ridiculous - you wouldn't have this issue.  Of course, you'd end up creating many more issues than you solve with that approach.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 7
(3,449 Views)