All pastes #339279 Raw Edit

Stuff

public text v1 · immutable
·published 2007-02-03 23:46 UTC
rendered paste body
string[] argv = Environment.GetCommandLineArgs();

string FileToUse = String.Empty;
string Potential = String.Empty;

string StartupPath = argv[0];
StartupPath = StartupPath.Substring(0, StartupPath.LastIndexOf('\\') + 1);

Potential = StartupPath + "default.vp1";

if (File.Exists(Potential)) {
	FileToUse = Potential;
}

if (argv.Length == 2) {
	if (File.Exists(argv[1])) {
		FileToUse = argv[1];
	} else if (Directory.Exists(argv[1])) {
		Potential = String.Format("{0}{1}{2}",
			argv[1],
			argv[1][argv[1].Length-1] == '\\'? String.Empty: "\\",
			"default.vp1");

		if (File.Exists(Potential)) {
			FileToUse = Potential;
		}
	}
}

if (FileToUse.Length == 0) {
	// uh oh
}