Example #1
0
        /// <summary>
        /// Copy the file
        /// </summary>
        /// <param name="fromFilePath">Original path</param>
        /// <param name="toFilePath">Destination path</param>
        /// <returns>Whether success</returns>
        public static bool CopyFile(string fromFilePath, string toFilePath)
        {
            try
            {
                CreateDirectoryByFilePath(toFilePath);
                if (File.Exists(toFilePath))
                {
                    File.Delete(toFilePath);
                }

                // 判断文件是否已经被占用
                if (IoHelper.WaitReady(fromFilePath))
                {
                    File.Copy(fromFilePath, toFilePath);
                }
            }
            catch (System.Exception ex)
            {
                LogHelper.Error(ex);

                return(false);
            }

            return(true);
        }
Example #2
0
        /// <summary>
        /// Write error log
        /// </summary>
        /// <param name="content">content</param>
        public static void Error(System.Exception content)
        {
            DateTime dt = DateTime.Now;

            lock (onlyForLockUse)
            {
                string appendContent = content.ToSafeString();

                Debug.WriteLine(GetContent(dt, appendContent));

                IoHelper.AppendStringLineToFilePath(GetFilePath(dt), GetContent(dt, appendContent));
            }
        }
Example #3
0
        /// <summary>
        /// Write error log
        /// </summary>
        /// <param name="content">content</param>
        /// <param name="args">arguments</param>
        public static void Error(string content, params object[] args)
        {
            DateTime dt = DateTime.Now;

            lock (onlyForLockUse)
            {
                string appendContent = content.FormatString(args);

                Debug.WriteLine(GetContent(dt, appendContent));

                IoHelper.AppendStringLineToFilePath(GetFilePath(dt), GetContent(dt, appendContent));
            }
        }
Example #4
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            //if (this._wordApplication != null)
            //{
            //    this._wordApplication.Quit();
            //}
            StringBuilder sb = new StringBuilder();

            foreach (string str in this._lstPath)
            {
                sb.AppendLine(str);
            }
            string filename = "history.txt";
            string path     = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string cfgName  = System.IO.Path.Combine(path, "ExamTester", filename);

            IoHelper.SaveStringToFilePath(cfgName, sb.ToString());
        }