示例#1
0
        /// <summary>
        /// 備份檔案
        /// </summary>
        static void BackupFile()
        {
            try
            {
                string targetFilePath = Path.Combine(
                    Di.FullName,
                    string.Format("{0}{1}_{2}{3}",
                                  Type == BuildType.Debug ? "d_" : "",
                                  Path.GetFileNameWithoutExtension(Fi.Name),
                                  FileVersionInfo.GetVersionInfo(Fi.FullName).FileVersion,
                                  Fi.Extension));

                Fi.CopyTo(targetFilePath);

                Console.WriteLine("Source : " + Fi.FullName + "\r\nTarget : " +
                                  targetFilePath + "\r\n" +
                                  (File.Exists(targetFilePath) ? "複製成功。" : "複製失敗。"));
            }
            catch (IOException) { throw; }
            catch (Exception) { throw; }
        }