If there is some sort of naming convention that is used for the files than this can be done as in Can i automatically load chapters and sections based on the filesystem?
\documentclass{article}
\newcommand*{\MaxNumOfChapters}{10}% Adjust these two settings for your needs.
\newcommand*{\MaxNumOfSections}{6}%
\usepackage{pgffor}%
\begin{document}
\foreach \c in {1,2,...,\MaxNumOfChapters}{%
\foreach \s in {1,2,...,\MaxNumOfSections}{%
\IfFileExists{Chapter\c/Section\s} {%
\input{Chapter\c/Section\s}%
}{%
% files does not exist, so nothing to do
}%
}%
}%
\end{document}
This assumes that there is a directory for each chapter named Chapter<i>
directory contains files named Section<n>
. Should be able to customize this depending on your specific case.
This should work across different operating systems.
If there is not specfic naming convention, you can adjust this to process a list of files generated by your C# program. For example, if the C# program can generate ListOfFiles.tex
as
\newcommand*{\ListOfFiles}{%
Chapter1/Section1,
Chapter1/Section2,
Chapter1/Section3,
Chapter2/Section1,
Chapter2/Section2
}%
then you can process this as:
\documentclass{article}%
\usepackage{pgffor}%
\input{ListOfFiles}%
\begin{document}%
\foreach \c in \ListOfFiles {%
\input{\c}%
}%
\end{document}
\app@exe{cmd /c dir /b *.txt > \jobname.tmp}
in Herbert's answer. On a sidenote, his code does work in Windows if you have the proper *nix tools provided by Cygwin or MSys. IMHO those tools give us more confidence than their Windows counterparts.