Skip to Content
Author's profile photo Jamie Wiseman

Displaying Text File Contents from a File Directory in Crystal Reports

If you have a directory structure containing text files, then you can display the directory information and the text file contents in Crystal Reports.



Here’s how:


1) first, download (and then install) the Wire Protocol (Data Direct) drivers for crystal reports from here. they are free for crystal reports customers and they are apparently faster than odbc and ole. they also have a great .txt driver that we will be using in this example.


2) create a new report off of the desired file structure folder using the File System Data connector in crystal reports.


3) in the Report > Selection Formulas > Record filter, create a selection formula similar to the syntax below.


 {yourdirectoryfoldername.Extension} = “txt”


drag any file / structure information onto this new report that you need.


4) outside of crystal, in your ODBC Data Source Administrator, create a new System DSN off of the CR Text ODBC Driver 5.3…this driver would be installed with the above-mentioned Data Direct drivers. the new system dsn would point to the same directory structure as the report created in step #2.  do not check “Column Names in First Line”


5) create another new report using the new ODBC connection created in step #4. for the data, press the Add Command and create a command with one string parameter with syntax similar to the syntax below.


select * from {?filename}


{?filename} is a new command string type parameter you create with a default value of any of the .txt files in your directory structure.


6) drag the field created by the command onto your report. save this report onto your desktop. 


7) go back to your original file structure report and go to Insert > Subreport. insert the new command based report (created in step #5) into the Details section.


8) for the Subreport Links, link the main report {yourdirectoryfoldername.File Name} field to the {?filename} prompt in the command based subreport.


9) preview the report.


You should now see all of the .txt file contents in the subreport where the .txt file corresponds to the file name in the main report.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      This says it is for Crystal Reports 2008.  Is a driver available for this that supports Crystal Reports v10? 
      Author's profile photo Jamie Wiseman
      Jamie Wiseman
      Blog Post Author
      hey Dave,
      there are datadirect drivers for v10 of cr available at

      choose crystal reports, crystal reports 10, and "other" as the software type.

      there are different versions of these drivers for different versions of cr. not 100% sure, but i think that these started in v9 of crystal???

      please note that this process outlined in the blog was only tested in cr 2008, so it may or may not work in other versions.

      Author's profile photo Former Member
      Former Member

      Great, useful post.  Thanks for sharing.