Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Name of files in a folder

Status
Not open for further replies.

fanta2

Technical User
Apr 10, 2005
78
CA
how can I know the name of the files that exist in the same directory as the fortran exe resides. Any help is appreciated!
 
Which compiler/operating system are you using?
 
I am using Compaq Visual Fortran with windows xp
 
Don't know about Compaq Visual Fortran. In g95, I'd do it like this
Code:
      program getdir
      character*32 fname
      integer dirlist
      parameter (dirlist = 10)
      call system ('dir /b > dirlist.txt')
      open (dirlist, file='dirlist.txt', status='old')
10    continue
         read (dirlist, *, end = 20) fname
         write (*,*) fname
         goto 10
20    continue
      close (dirlist)
      stop
      end
You can check and not print dirlist.txt and even delete it after the close.
 
Thanks xwb! It works perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top