예제 #1
0
파일: NetMgr.cs 프로젝트: midgithub/notes
        public void SaveNetFlow(int sent, int recv)
        {
#if UNITY_EDITOR
            float  sentflow = sent / RECORD_GAP;
            float  recvflow = recv / RECORD_GAP;
            string t        = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string msg      = string.Format("{2} down:{0}B/s      up:{1}B/s", UiUtil.NumberToString((int)recvflow, 6), UiUtil.NumberToString((int)sentflow, 6), t);
            LogMgr.Log(msg);

            //追加到文件
            string     file   = Application.dataPath + "/../Net.log";
            FileStream stream = new FileStream(file, FileMode.OpenOrCreate);
            stream.Position = stream.Length;            //跳到末尾
            StreamWriter writer = new StreamWriter(stream);
            writer.Write(msg);
            writer.WriteLine();
            writer.Flush();
            writer.Close();
            writer.Dispose();
            writer = null;
            stream = null;
#endif
        }