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: 

Reading a binary file

Solved!
Go to solution

I'm trying to read a file which is in binary, and I've been uncessful, I get the following error message: Error 7 occurred at Open/Create/Replace File in TESTEXAMPLE.vi, and the possible reason is: LabVIEW:  File not found. The file might be in a different location or deleted. Use the command prompt or the file explorer to verify that the path is correct.  Currently the program is in the same folder as the file I'm trying to read, so I'm not sure if I'm setting it up correctly. 

 

Thanks, 

Andrea 

0 Kudos
Message 1 of 7
(4,358 Views)
Solution
Accepted by topic author AndreaD

Replace default data directory with application directory and build that path with the file name.  You can always probe the wire to see what the path actually is.



-Matt
0 Kudos
Message 2 of 7
(4,355 Views)

When called from the VI, "Application directory" will be Labview folder, If it is executable, then it is folder of executable, not always convenient. Also Windows approach is that Program Files folder should have restricted access and not to be used for user data.

I prefer to use folders relative to windows constants: File functions -> File Constants -> Get System directory, then User desktop, User documents or other location for data.

Default LabVIEW data folder is Current User Documents\LabVIEW data, or can be changed in Tools -> Options -> Paths to something fixed.

Message 3 of 7
(4,341 Views)

@Alexander_Sobolev wrote:

When called from the VI, "Application directory" will be Labview folder, If it is executable, then it is folder of executable, not always convenient.


If you are using a project, like you should be for everything now, then the Application Directory returns the folder of the project file.  This is when it is extremely useful (bouncing between Project and Executable).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 7
(4,327 Views)

If you actually have the file somewhere and you are just trying to test things out, the simplest, fastest, most-error-free way to use Open/Create is to wire a constant to the Input.  Now, right-click the Constant, choose "Browse for Path", and navigate to your file.  Now you'll open exactly that specific file.

 

Bob Schor 

Message 5 of 7
(4,312 Views)

@crossrulz wrote:

If you are using a project, like you should be for everything now, then the Application Directory returns the folder of the project file.  This is when it is extremely useful (bouncing between Project and Executable).

Project - yes and always.

Application directory function - yes, path to project location. Application directory property - path to LabVIEW. Anyway you need to distinguish between exe and vi.

Message 6 of 7
(4,298 Views)

Alexander_Sobolev wrote: Application directory property - path to LabVIEW.

I have never seen anybody actually try to use that in actual code for this purpose.  But it does make since when in the dev environment since the application you are running is technically LabVIEW.exe.  The Application Directory function knows better and will return the project's folder if there is one.

 


Alexander_Sobolev wrote:  Anyway you need to distinguish between exe and vi.

No need to distinguish when using the Application Directory function.  In in an executable, it returns the folder of the exe.  If you have your directory structures set up half way intelligently, then the relative paths between your files and the project file should match that of the files and the executable.  Therefore, you do not have to worry about which environment you are in.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 7
(4,289 Views)