NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member Lab
Member
Lab
Posts: 61
0 Kudos

How can I get subdirectory list in one dir in LabWINDOWS ?

I know there are GetFirstFile and GetNextFile in LabWINDOWS,Is there such functions for Dir?
Trusted Enthusiast
RobertoBozzolo
Posts: 4,528

Re: How can I get subdirectory list in one dir in LabWINDOWS ?

I'm not aware of a native method to obtain the directory listing; you could try using the system DIR command redirecting output to a file and reading the output file.

The command DIR /a:d /b > file.txt creates a file with the name of the subdirectories found in directory. The file can next be processed line by line to manage results.

Hope this helps
Roberto



Using LW/CVI from 3.1 on.

My contributions to the Developer Zone Community
________________________________________
If I have helped you, why not giving a kudos?
Member Lab
Member
Lab
Posts: 61
0 Kudos

Re: How can I get subdirectory list in one dir in LabWINDOWS ?

Can I achieve your method in LabWINDOWS?run some DOS command?
Trusted Enthusiast
RobertoBozzolo
Posts: 4,528
0 Kudos

Re: How can I get subdirectory list in one dir in LabWINDOWS ?

Yes, you can use the system () command that waits for the function to end before return.

As an alternative you can use LaunchExecutable () that doesn't wait for program conclusion or even better LaunchExecutableEx () that permits you to hide the window for the launched program. In these cases, you will need to use ExecutableHasTerminated () in a loop to be sure the process is terminated before processing the results.

Roberto



Using LW/CVI from 3.1 on.

My contributions to the Developer Zone Community
________________________________________
If I have helped you, why not giving a kudos?
Member Lab
Member
Lab
Posts: 61
0 Kudos

Re: How can I get subdirectory list in one dir in LabWINDOWS ?

I used system("command.com /C dir g:\\0907\\FT/a:d/b> FILE.txt"); But I got following in FILE.txt,

FT1601~1
FT1601~2
FT1601~3
FT1601~4
FTFAAC~1
FTFABC~1
FT1660~1
FTFA54~1
FTFA64~1
FTFA74~1
FTFA84~1
FTFA94~1
FTFAA4~1
FTFAB4~1
FTFAC4~1
FTFA3C~1
FTFA44~1
FTFA4C~1
FTFA5C~1
In fact,it should be
FT1601A-013
FT1601A-014
FT1601A-015
FT1601A-016
FT1601A-017
FT1601A-018
FT1660A-010
FT1601A-002
FT1601A-003
FT1601A-004
FT1601A-005
FT1601A-006
FT1601A-007
FT1601A-008
FT1601A-009
FT1601A-010
FT1601A-001
FT1601A-011
FT1601A-012
Active Participant
msaxon
Posts: 394

Re: How can I get subdirectory list in one dir in LabWINDOWS ?

Depite the function names, you can use GetFirstFile() and GetNextFile() to list directory names as well.

e.g. result = GetFirstFile ("C:\\SearchPath\\*", 0, 0, 0, 0, 0, 1, fileName);

--
Martin
--
Martin
Certified CVI Developer
Member Lab
Member
Lab
Posts: 61
0 Kudos

Re: How can I get subdirectory list in one dir in LabWINDOWS ?

thank you very much
Member Lab
Member
Lab
Posts: 61
0 Kudos

Re: How can I get subdirectory list in one dir in LabWINDOWS ?

Can I get DirName[] order by name of dir?
k1 k2 k3 k4,but k2 k1 ...
Active Participant
msaxon
Posts: 394
0 Kudos

Re: How can I get subdirectory list in one dir in LabWINDOWS ?

Not with that function, you would have to sort the list yourself.

--
Martin
--
Martin
Certified CVI Developer
Member
mkossmann
Posts: 61
0 Kudos

Re: How can I get subdirectory list in one dir in LabWINDOWS ?


Lab wrote:
I used system("command.com /C dir g:\\0907\\FT/a:d/b> FILE.txt"); But I got following in FILE.txt,
FT1601~1
...

In fact,it should be
FT1601A-013
...

 

Looks like that you get only the short names ( truncated to 8.3 format). If you are on NT or newer you might try cmd.exe instead of command.com


 

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page