From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

check if file or folder

Hi,

 

The "check if file or folder exists?" returns false when there is a folder in c drive. So I added a "create folder" if false. Now it returns true, but there is no file in c:

What could be the problem?

 

0 Kudos
Message 1 of 23
(5,666 Views)

Hi kdm,

 

could you attach the VI or at lest the part where you check the folder presence do debug it?

Duri
0 Kudos
Message 2 of 23
(5,664 Views)

kdm7 wrote:

The "check if file or folder exists?" returns false when there is a folder in c drive. So I added a "create folder" if false. Now it returns true, but there is no file in c:

What could be the problem?


We need more details. Whatever you wrote is very confusing:

 

  • When there is a folder, the function should return true, not false.
  • After you create a folder, there should be a folder, not a file.

You need to show us your code.

0 Kudos
Message 3 of 23
(5,650 Views)

I meant after I create a folder, there is no folder( therefore no file too) in c drive.

 

Here is my code.

0 Kudos
Message 4 of 23
(5,631 Views)

Hi kdm,

 

you should have learned by now that attaching just a LVPROJ file will be (mostly) senseless.

We need your VIs!

 

Judging from your LVPROJ file:

Where did you check the file/folder creation?

There are two VIs in your sbRIO target. When you create files/folders on your sbRIO you will have to check for their presence on exactly that sbRIO target!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 23
(5,625 Views)

I checked for it in the test2_rt(2) vi.

What do you mean by "When you create files/folders on your sbRIO you will have to check for their presence on exactly that sbRIO target!"?

(I checked it in c drive. Can't I create log file on c drive?)

Here are my VIs.

Download All
0 Kudos
Message 6 of 23
(5,616 Views)

Hi kdm,

 

you didn't say where you checked for those folder(s) and file(s)…

 

But your "test2_rt (2).vi" shows a big, very big, HUGE problem:

You create a file path by using string constants. THAT'S PLAIN WRONG! Use path constants whenever you want to handle paths!

 

check.png

Best regards,
GerdW


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

Hi Gerd,

 

Now I've changed it. Thanks.

 

But I'm still not able to find the log file. I checked it in c drive.

I use sbRIO 9641. How do you check whether it is on the sbRIO target?

There is small green circle on the "NI-sbRIO9641-01624006" line. It indicates that the device is connected and I have the VIs under them. Does that mean I'm on the sbRIO 9641 target?

0 Kudos
Message 8 of 23
(5,587 Views)

Do you make sure to create the NewTest directory before writing to a file in it?

Do you check the error that CreateDirectory returns?

Do you check the error that Write to Spreadsheet file or whatever other function you use to write to the file does return?

Rolf Kalbermatter
My Blog
Message 9 of 23
(5,573 Views)

Hi rolfk,

 

Yes, I have the NewTest folder created.

No error returned from create folder 

No error returned from Write to text file either.

 

 

0 Kudos
Message 10 of 23
(5,552 Views)