How to list all text files in a directory?

How to list text files in a directory in Progress 4GL?

  • I have a folder in c drive,whicn contain 1000 txt file,i want to get the list of all these txt file. How can i get this list?

  • Answer:

    Use the OS-DIR() function. For example: DEFINE STREAM dirlist. DEFINE VARIABLE filename AS CHARACTER FORMAT "x(30)" NO-UNDO. INPUT STREAM dirlist FROM OS-DIR("."). REPEAT: IMPORT STREAM dirlist filename. DISPLAY filename. END. INPUT CLOSE.

Jay at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

For example: ipcPath = "C:\temp\ DEFINE INPUT PARAMETER ipcPath AS CHARACTER NO-UNDO. DEFINE VARIABLE chFiles AS CHARACTER NO-UNDO. INPUT FROM OS-DIR(ipcPath). REPEAT: IMPORT UNFORMATTED chImport NO-ERROR. DISPLAY chFiles FORMAT "X(75)". END. INPUT CLOSE. chFiles is a spacedelimeted list and contains the filename, the path, and an 'F' or 'D' tag.

Demian Kasier

I have a directory-tools program which enable a developer to do all kinds of fun things with file systems. You can get the code here: http://communities.progress.com/pcom/docs/DOC-16578

Tim Kuehn

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.