Hi All,
I am trying to make two changes to the block of C# code at the bottom of this page. Any help would be greatly appreciated!
1) the input files are not currently valid XML files, so I used to run the following script first. Is there anyway to replicate the exact functionality of this script in the C# code (such that as the C# app opens each file, it first performs this modification)?
Code:
while read THISFILE
do
echo '<uspto>' > /tmp/patentconversion.xml
cat $THISFILE \
| grep -v '<?xml' \
| grep -v '<!DOCTYPE' \
| grep -v '<!ENTITY' \
| grep -v ']>' \
| tr '\n#&\t' ' ' \
>> /tmp/patentconversion.xml
echo '</uspto>' >> /tmp/patentconversion.xml
done
2) Instead of creating a separate output file for each file, how can I modify the C# code such that each additional output is appended to the first output file (i.e. all files get outputted to the same c:\code-gen\output\" + file.Name file)?
Code:
// create directory object
System.IO.DirectoryInfo dirCustom = new System.IO.DirectoryInfo(@"c:\code-gen\employees");
//use GetFiles method to get all the files in the directory
System.IO.FileInfo[] filCustom = dirCustom.GetFiles();
//create the "output" directory
System.IO.Directory.CreateDirectory(@"C:\code-gen\output");
//iterate through each file in turn, create a source and target object for each file, then pass this to the Run method
foreach (System.IO.FileInfo file in filCustom)
{
Altova.IO.Input source2Source = new Altova.IO.FileInput(@"C:\code-gen\employees" + file.Name);
Altova.IO.Output target2Target = new Altova.IO.FileOutput(@"c:\code-gen\output\" + file.Name);
MappingMapTotargetObject.Run(
source2Source,
target2Target);
}