ok so this is a little code snippet. Lets say I have 10 text files in a folder and I want to add my ASCII signature to the end of all of them. I can put them in an array, and use a Foreach loop to do it to all of them at once. Heres how:
public static void write(String[] files)
{
foreach (String s in files)
{
FileStream fs = new FileStream(s, FileMode.Open, FileAccess.Write);
String[] line = {" ..jjLLtt \r\n",
" GGffiiGGLL \r\n",
" iiDD ,,EE,, \r\n",
" ttGG EEii \r\n",
" ;;EE.. ;;EEtt \r\n",
" LLEEffGGEEtt \r\n",
" ;;;;..KK;; \r\n",
" ;;,, ;;KK.. ;;;; \r\n",
" ..KKDD ii,,;;EEtt KKEE \r\n",
" ..LLtt LLDDDDtt LLjj \r\n"};
for (int i = 0; i < line.Length; i++)
{
Byte[] buffer = System.Text.Encoding.ASCII.GetBytes(line[i]);
try
{
fs.Write(buffer, 0, line[i].Length);
}
catch (Exception e)
{
// Do Nothing
}
}
fs.Close();
}
Now unfortunately because it gets rid of all the tabs, you can see what it actually looks like, but you can see it here
The parameter for the write method is an array of strings. The strings in this case happen to be file names. So the method will take all the filenames into it, and for each one, open them in a filestream, and using the filestream for each one, will write the ASCII signature in the file, and then close the filestream.