Thanks for trying Cmdr, but that didn't work for me. I had some errors in my code, and once I fixed that the code worked, but it still wouldn't print to the command line. I'm kind of lost still. I guess I will have to do some more research on MSDN. Here is the updated code that works.
using System;
using System.IO;
using System.Windows.Forms;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
namespace WindosApps
{
/// <summary>
/// Description of RenameFiles_Console.
/// </summary>
public class RenameFiles_Console
{
private static void Main(string[] args)
{
try {
Console.WriteLine("Starting work.");
if ( (args == null) || ( !args.Length.Equals(3) ) ) {
Console.WriteLine("Arguements: <Path> <Series number> <Start sheet number>");
return;
}
//MessageBox.Show("1");
Console.WriteLine("Starting work.");
string DirPath = args[0] as string;
if ( !Directory.Exists(DirPath) ) {
Console.WriteLine("Directory does not exist.");
return;
}
//MessageBox.Show("2");
Console.WriteLine("Done with directory.");
string SeriesPrefix = args[1] as string;
if ( !SeriesPrefix.Length.Equals(14) ) {
Console.WriteLine("Series number is not the correct length: <12-2xxx-xxxx-x>");
return;
}
//MessageBox.Show("3");
Console.WriteLine("Done checking series number.");
int SheetNumber = Convert.ToInt16(args[2]);
if (SheetNumber <= 0) {
Console.WriteLine("Starting sheet number has to be greater than 0.");
return;
}
Console.WriteLine("Done checking sheet number.");
foreach (string str in Directory.GetFiles(DirPath, "*.dwg")) {
string strSheetNumber = SheetNumber.ToString();
if (SheetNumber < 10)
strSheetNumber = "00" + strSheetNumber;
else if (SheetNumber < 100)
strSheetNumber = "0" + strSheetNumber;
string tempNewPath = DirPath + "\\" + SeriesPrefix + "_" + strSheetNumber + ".dwg";
//MessageBox.Show(tempOldPath + "\n" + tempNewPath);
File.Copy(str, tempNewPath);
if ( File.Exists(tempNewPath) ) {
File.Delete(str);
Console.WriteLine("Renamed " + str + " -> " + tempNewPath);
}
else
Console.WriteLine("Could not rename file: " + str);
++SheetNumber;
}
}
catch (System.Exception SysEx) { Console.WriteLine(SysEx.Message); }
finally {
//Console.ReadLine();
}
return;
}
}
}