Example #1
0
 /// <summary>
 /// 检件文件夹是否存在,不存在则创建
 /// </summary>
 /// <param name="FileName">文件名</param>
 public static void CheckFolderExistsViaFileName(string FileName)
 {
     System.IO.FileInfo fileInfo = new System.IO.FileInfo(FileName);
     if (fileInfo != null)
     {
         DxPublic.CheckFolderExists(fileInfo.DirectoryName);
     }
 }
Example #2
0
 /// <summary>
 /// OBJECT类型转时间格式
 /// </summary>
 /// <param name="obj">obj对象</param>
 /// <returns></returns>
 public static DateTime GetObjDateTime(object obj)
 {
     if (DxPublic.IsObjNull(obj))
     {
         return(new System.DateTime(2020, 1, 1));
     }
     return(System.Convert.ToDateTime(obj));
 }
Example #3
0
        /// <summary>
        /// Obj转成GUID
        /// </summary>
        /// <param name="obj">对象</param>
        /// <returns></returns>
        public static System.Guid GetObjGUID(object obj)
        {
            string objectString = DxPublic.GetObjString(obj);

            System.Guid result;
            if (!System.Guid.TryParse(objectString, out result))
            {
                result = System.Guid.Parse("00000000-0000-0000-0000-000000000000");
            }
            return(result);
        }
Example #4
0
        /// <summary>
        /// 异常信息提示
        /// </summary>
        /// <param name="ex">异常</param>
        /// <param name="Caption">提示框名称</param>
        public static void ShowExceptionFormat(Exception ex, string Caption = "系统提示")
        {
            string content = string.Format("Message:{0} {1} Source:{2} {1} StackTrace:{3}", new object[]
            {
                ex.Message,
                System.Environment.NewLine,
                ex.Source,
                ex.StackTrace
            });

            DxPublic.ShowMessage(MessageBoxIcon.Hand, content, Caption);
        }
Example #5
0
        /// <summary>
        /// 读取文件文本信息
        /// </summary>
        /// <param name="FileName">文件名</param>
        /// <returns></returns>
        public static string ReadTextFile(string FileName)
        {
            if (!DxPublic.GetFileExists(FileName))
            {
                throw new System.Exception("文件不存在!!");
            }
            System.IO.StreamReader streamReader = null;
            string result;

            try
            {
                streamReader = new System.IO.StreamReader(FileName, System.Text.Encoding.UTF8);
                result       = streamReader.ReadToEnd();
            }
            finally
            {
                if (streamReader != null)
                {
                    streamReader.Close();
                    streamReader.Dispose();
                }
            }
            return(result);
        }
Example #6
0
 /// <summary>
 /// 获取打开的XLS文件名称
 /// </summary>
 /// <param name="DefaultFileName">默认文件名</param>
 /// <returns></returns>
 public static string GetOpenXlsFileName(string DefaultFileName)
 {
     return(DxPublic.GetOpenFileName("EXCEL File(*.xls)|*.xls", DefaultFileName));
 }
Example #7
0
 /// <summary>
 /// Obj转成大定的String类型
 /// </summary>
 /// <param name="obj">对象</param>
 /// <returns></returns>
 public static string GetObjStrUpperTrim(object obj)
 {
     return(DxPublic.GetObjString(obj).Trim().ToUpper());
 }