LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Open/Create/Replace File and Windows Permissions

Solved!
Go to solution

I've written a program that searches through my company's collection of Test Data .txt files for a particular serial number, entered by the user, and returns PASS/FAIL information.  The test data is stored on a network drive, and searching for files manually in Windows Explorer can take MUCH longer than my program.  

 

I've got a user that can't seem to get any data out of my program, and it seems to be a permissions issue, except that she has "Read" access to the folder, evident by the fact she can open and copy and move files from the test data folder to locations on her C:\ drive.  This user is working remote, and has to VPN into the server I believe, but I'm not entirely sure how that works in my company.  Other users of this program inside my facility do not have the same issue, but I don't have access to see their Windows folder permissions to be able to compare.  

 

Here's my code:

Wiley85_0-1761225326332.png 

Wiley85_1-1761225566527.png

 

 

This portion of the code is pretty basic, just concatenating a file path onto a Serial Number to be searched, along with some test-type characters, then an iteration (each time a test operator re-runs a test, the test data name iterates) followed by the .txt extension.  In normal operation, while loop will iterate once more than the number of copies of a serial number test, so if there's only one copy of the test data, the while loop iterates twice.  I put the "Search Array" in there for debugging, when I run the program I get a "0" in the first index and a "7" in the second index, which is expected, but my problem user gets a "7" in the first index, indicating it fails to even open a test data file once.

 

As you can see, I'm using the "OPEN" and "READ ONLY" options, and I read that to mean as long as the Windows user has "READ" access to a file or folder, this operation should work?  Do I need to include some kind of timing buffer to account for her remote-ness?  Am I going to need to wade into the morass of Windows File Security and Corporate Permissions?

 

Thanks in advance for your advice and wisdom!

0 Kudos
Message 1 of 13
(315 Views)
  • Is there a difference between the two pictures you have attached?
  • Why would you need to open a file to determine its existence?
  • Wy would you need to read the same array local variable with every iteration of the outer loop? Is there a chance that it can change during iterations? Wouldn't it make much more sense to just autoindex on that array?
  • Do they get any errors?

(In general, it is difficult to debug code pictures.)

0 Kudos
Message 2 of 13
(285 Views)
  • Is there a difference between the two pictures you have attached?
    Difference between two pictures is the small case structure, showing that when the Open/Create/Replace succeeds in opening a file, it also gets closed, but if it fails to open a file, it doesn't close anything preventing further errors
  • Why would you need to open a file to determine its existence?
    This portion of code serves to determine the highest iteration of test files for a given serial number, later on I open that file again to determine PASS/FAIL information.  This was the easiest way I could see to do it, but an easier/better way might exist?
  • Wy would you need to read the same array local variable with every iteration of the outer loop? Is there a chance that it can change during iterations? Wouldn't it make much more sense to just autoindex on that array?
    On that outer loop, a separate vi is filling in different filepaths to the concatenate string, and they don't necessarily index well.  Each time I use a different filepath for where test data is stored, I need to use the same set of serial numbers provided by the user.
  • Do they get any errors?
    She is getting error code 7 when the while loop iterates the first time, which NI has indicated can be caused by a number of things including permission issues.  Apologies for not providing more information about the code or specific permissions, I'd rather be cautious about what I provide here to avoid security issues with IT...

(In general, it is difficult to debug code pictures.)

0 Kudos
Message 3 of 13
(257 Views)

You might want to consider using Create File with Incrementing Suffix VI  as it does the work of keeping track of the next number to increment for you.

 

But give us an example of what a standard path and filename looks like, that might help in figuring out the permissions issue.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 13
(252 Views)

I totally thought I put that in my original comment!  Here's what a typical file looks like:

 

C37370-0-DCRF.txt 

 

where C37370 is the Serial Number, 0 is the test iteration, and DCRF is the type of test run.

 

Sorry about that oversight!

0 Kudos
Message 5 of 13
(245 Views)

@Wiley85 wrote:

I totally thought I put that in my original comment!  Here's what a typical file looks like:

 

C37370-0-DCRF.txt 

 

where C37370 is the Serial Number, 0 is the test iteration, and DCRF is the type of test run.


 

Can't you do a "list folder" with "C37370-*-DCRF.txt" as pattern, then search through the output? (There is even a recursive file list version).

 

I also strongly recommend to pad the test iteration with a sufficient number of zeroes (e.g. 0000, 0001, etc.) such that alphabetical sorting=numerical sorting.

 

 

0 Kudos
Message 6 of 13
(239 Views)

@Wiley85 wrote:
  • Wy would you need to read the same array local variable with every iteration of the outer loop? Is there a chance that it can change during iterations? Wouldn't it make much more sense to just autoindex on that array?
    On that outer loop, a separate vi is filling in different filepaths to the concatenate string, and they don't necessarily index well.  Each time I use a different filepath for where test data is stored, I need to use the same set of serial numbers provided by the user.

 

Sorry, I don't understand your explanation. Auto-indexing on an array is functionally identical to indexing into the array with [i] (and you don't even need to wire N unless you don't want to process all elements. reading from a local variable in an inner loop is dangerous because you can't know if the value changes mid-stream, potentially breaking everything. it is also inefficient, because the compiler must assume that it can change at any time. What if you are at iteration 100 and the local variable turns into an empty array?

 

Compare:

 

altenbach_0-1761242759183.png

 

 

 

0 Kudos
Message 7 of 13
(236 Views)

I guess maybe I misunderstand the question.  The local variable doesn't change while the program is running, and will likely never contain 100 entries, it's simply a list of serial numbers the user wants to check for test data.  In a previous section of my code, I've given the user the option to enter just a single serial number, a range of serial numbers, or a scattered list of SN's, all of which get shoved into that local variable for use by this portion of my code.  In diagnosing this issue, I replaced the local variable with a simple tunnel from the previous section to hopefully eliminate the inefficiencies mentioned, and the code still does what I expect.

0 Kudos
Message 8 of 13
(228 Views)

@Wiley85 wrote:

I totally thought I put that in my original comment!  Here's what a typical file looks like:

 

C37370-0-DCRF.txt 

 

where C37370 is the Serial Number, 0 is the test iteration, and DCRF is the type of test run.

 

Sorry about that oversight!


Sure but what is the complete path. C:\blah\blah\blah\blah\C37370-0-DCRF.txt 

I ask because I have had path issues cause Error 7

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 9 of 13
(220 Views)

Below are some of the filepaths searched in order:

 

B:\A_GPSS TEST DATA\TEST DATA\Fin Good Test Data\

B:\A_GPSS TEST DATA\TEST DATA\Fin Good Test Data Archive\

B:\A_GPSS TEST DATA\TEST DATA\Fin Good Test Data Archive 2025\

B:\A_GPSS TEST DATA\TEST DATA\Fin Good Test Data Archive 2024\

 

0 Kudos
Message 10 of 13
(213 Views)