示例#1
0
    // ========================================================================================================================

    IEnumerator SaveLogFile_Coroutine(string strFileName, OnGetFileString OnGetLogLine)
    {
        if (string.IsNullOrEmpty(strFileName))
        {
            strFileName = SystemInfo.deviceUniqueIdentifier;
        }
        string strLogFilePath = string.Format("{0}/{1}.txt", _strLogFolderPath, strFileName);

        Debug.Log("Save Log Path : " + strLogFilePath);
        if (System.IO.Directory.Exists(_strLogFolderPath) == false)
        {
            System.IO.Directory.CreateDirectory(_strLogFolderPath);
        }

        using (System.IO.FileStream pFileStream = new System.IO.FileStream(strLogFilePath, System.IO.FileMode.Create, System.IO.FileAccess.Write))
            using (System.IO.StreamWriter pWriter = new System.IO.StreamWriter(pFileStream))
            {
                bool bIsFinish = false;
                while (bIsFinish == false)
                {
                    pWriter.WriteLine(OnGetLogLine(out bIsFinish));

                    yield return(null);
                }
            }

        yield break;
    }
示例#2
0
    public IEnumerator DoSendMail_WithLogFile_Coroutine(string strMailTitle, string strMailBody, string strLogFileName, OnGetFileString OnGetLogLine)
    {
        yield return(SaveLogFile_Coroutine(strLogFileName, OnGetLogLine));

        string   strPath_txt = string.Format("{0}/{1}.txt", _strLogFolderPath, strLogFileName);
        FileInfo pFileInfo   = new FileInfo(strPath_txt);

        if (pFileInfo == null)
        {
            yield break;
        }

        string strFileSize = (pFileInfo.Length / 1024) + "KB";

        Debug.Log($"Send Email Size : {strFileSize} // FilePath : {strPath_txt}");

        yield return(null);

        try
        {
            SendEmail(strMailTitle, strMailBody, strPath_txt);
            Debug.Log("Send Email Complete.");

            try
            {
                File.Delete(strPath_txt);
            }
            catch (System.Exception e)
            {
                Debug.LogError("Delete Zip2 Exception :" + e.ToString());
            }
        }
        catch (System.Exception e)
        {
            Debug.Log("Send Email Error \n" + e.ToString());
        }
    }