Skip to content

Instantly share code, notes, and snippets.

@rtipton
Created October 26, 2010 19:19
Show Gist options
  • Save rtipton/647585 to your computer and use it in GitHub Desktop.
Save rtipton/647585 to your computer and use it in GitHub Desktop.
C# -- Write a File Listing to a txt File
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace CheckUploadH
{
class Program
{
static void Main(string[] args)
{
string targetFile = @"O:\Work\Remits\uploadh_log.TXT";
StreamWriter sw;
sw = File.AppendText(targetFile);
string directoryToCheck = @"U:\";
string[] dirs = Directory.GetFiles(directoryToCheck, "*.835");
sw.WriteLine(DateTime.Now);
sw.WriteLine("-");
foreach (string dir in dirs)
{
Console.WriteLine(dir);
sw.WriteLine(dir);
}
sw.WriteLine("===========================================================");
sw.Close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment