internal static void SaveLastTempCode(string code, string tempOutPath)
        {
            if (string.IsNullOrEmpty(tempOutPath))
            {
                return;
            }

            try
            {
                string filePath = Path.Combine(tempOutPath, "__last_temp_code.cs");
                RetryFile.WriteAllText(filePath, code);
            }
            catch
            {              /* 输出最近一次运行时运行的代码,方便调试程序,忽略写文件出现的异常。 */
            }
        }
Example #2
0
        /// <summary>
        /// 取消文件的只读设置
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static void ClearReadonly(string filePath)
        {
            FileAttributes attributes = RetryFile.GetAttributes(filePath);

            if (attributes.HasFlag(FileAttributes.ReadOnly) == false)
            {
                return;
            }

            // 清除只读属性
            attributes &= ~FileAttributes.ReadOnly;

            CreateRetry().Run(() => {
                File.SetAttributes(filePath, attributes);
                return(1);
            });
        }
        internal static void SaveLastCompileError(CompilerResults cr, string tempOutPath)
        {
            if (string.IsNullOrEmpty(tempOutPath))
            {
                return;
            }

            try
            {
                string errorText = GetCompileErrorMessage(cr);
                string filePath  = Path.Combine(tempOutPath, "__last_CompilerError.txt");
                RetryFile.WriteAllText(filePath, errorText);
            }
            catch
            {              /* 输出最近一次运行时运行的异常,方便调试程序,忽略写文件出现的异常。 */
            }
        }
Example #4
0
 /// <summary>
 /// 判断文件是否为隐藏文件
 /// </summary>
 /// <param name="filePath"></param>
 /// <returns></returns>
 public static bool IsHidden(string filePath)
 {
     return(RetryFile.GetAttributes(filePath).HasFlag(FileAttributes.Hidden));
 }