|
using System;
using System.Diagnostics;
using System.IO;
namespace BeauSkinner.VerCopy
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class VerCopy
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static int Main(string[] args)
{
if (args.Length == 0 || args.Length > 2)
{
Console.WriteLine("Usage: VerCopy <filename> [destination-dir].\n");
return 1;
}
string PathFile = args[0];
FileInfo fileInfo = new FileInfo(PathFile);
if (!fileInfo.Exists)
{
Console.WriteLine("File does not exist.");
return 1;
}
string destPath = null;
if (args.Length == 2)
{
destPath = args[1].Trim("\\".ToCharArray());
if (!Directory.Exists(destPath))
Directory.CreateDirectory(destPath);
}
FileVersionInfo verInfo = FileVersionInfo.GetVersionInfo(PathFile);
string destFile = fileInfo.Name.Substring(0,fileInfo.Name.Length-fileInfo.Extension.Length) + "-"
+ verInfo.FileMajorPart + "-" + verInfo.FileMinorPart + "-" + verInfo.FileBuildPart + fileInfo.Extension;
if (destPath != null)
destFile = destPath + "\\" + destFile;
File.Copy(PathFile, destFile, true);
return 0;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.