using System; using System.Collections.Generic; using System.Windows.Forms; using System.IO; namespace ImageSorter { static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Form1 form = new Form1(); form.Show(); string directory = null; for (int i = 0; i < args.Length; ++i) { if (args[i].StartsWith("-")) { throw new ArgumentException("Bad arg " + args[i]); } else { if (directory == null) { directory = args[i]; } else { throw new ArgumentException("Unexpected argument " + args[i] + " -- you can only give one directory"); } } } if (directory == null) { // pop up a box for the user to choose OpenFileDialog dlg = new OpenFileDialog(); dlg.InitialDirectory = @"C:\pics"; dlg.Title = "Select a file, the WHOLE DIRECTORY will be used"; if (dlg.ShowDialog() != DialogResult.OK) { return; } directory = Path.GetDirectoryName(dlg.FileName); } form.LoadFromDirectory(directory); Application.Run(form); } } }