Beispiel #1
0
        static private string GetFileName(EFlagFileExportType eFloagFileExportType)
        {
            if (string.IsNullOrEmpty(_strLogFileName))
            {
                _strLogFileName = "Log";
                System.DateTime sDateTime = System.DateTime.Now;
                switch (_eFileNameType)
                {
                case EFileNameType.OnSecond: _strLogFileName += sDateTime.ToString("_MMdd_HH_mm_ss"); break;

                case EFileNameType.OnMinute: _strLogFileName += sDateTime.ToString("_MMdd_HH_mm"); break;

                case EFileNameType.OnHour: _strLogFileName += sDateTime.ToString("_MMd_HH"); break;

                case EFileNameType.OnDay: _strLogFileName += sDateTime.ToString("_MMdd"); break;

                case EFileNameType.OnMonth: _strLogFileName += sDateTime.ToString("_MM"); break;
                }
            }

            string strLogFileName = _strLogFileName;

            strLogFileName += const_mapExtensionName[eFloagFileExportType];
            return(strLogFileName);
        }
Beispiel #2
0
        static private void ProcWriteTo_File(string strText, EFlagFileExportType eFileType)
        {
            string strFilePath = Path.Combine(_strLogFilePathAll, GetFileName(eFileType));

            try
            {
                if (File.Exists(strFilePath) == false)
                {
                    string strDirectory = Path.GetDirectoryName(strFilePath);
                    if (Directory.Exists(strDirectory) == false)
                    {
                        Directory.CreateDirectory(strDirectory);
                    }

                    File.WriteAllText(strFilePath, strText, Encoding.UTF8);
                }
                else
                {
                    File.AppendAllText(strFilePath, strText, Encoding.UTF8);
                }
            }
            catch (Exception e)
            {
                UnityEngine.Debug.LogError("File Write Error - " + strFilePath + " Exception : " + e);
            }
        }