Example Code

File Path Checker - helping to prevent file/folder overwrites - Using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview
This example allows your code to automatically detect if a specified file or folder already exists.


Description

This simple little SubVI allows your code to automatically detect if a specified file or folder already exists - and if it does exist the algorithm adds an incrimentally increasing interger to the end of the filefolder path, until it is unique - thereby, preventing you overwriting any files/folders.


Requirements

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

1. Run the VI once - it will create a Folder called Test Sub Folder in the Application Directory, and the Path Modifed? LED will be off.

2. Run the VI subsequent times, and the VI will detect that the Test Sub Folder already exsists, and will create a Test Sub Folder1, Test Sub Folder2, Test Sub Folder3 instead. The Path Modifed LED will be on.

 

Additional Information or References
VI Snippet

356.png

**This document has been updated to meet the current required format for the NI Code Exchange.**

 

 

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Fuzzy Me
Member
Member
on

This VI will not incremant in sequence with last increment. ie if test sub folder 2 selected next should be

test sub folder 3 and not test sub folder 21