Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fileName">Path.</param>
        /// <param name="data">Data.</param>
        public static void WriteAllText(string fileName, string data)
        {
            try
            {
                string dir = HS_Path.GetDirectoryName(fileName);

                HS_Directory.CreateDirectory(dir);

                StreamWriter sw = new StreamWriter(fileName, false, Encoding.UTF8);
                sw.Write(data);
                sw.Flush();
                sw.Close();
            }
            catch (Exception _e)
            {
                D.LogErrorForce(_e.StackTrace);
            }
        }
Пример #2
0
        /// <summary>
        /// 一行一行的写
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="contentList"></param>
        public static void WriteWithLine(string fileName, string[] contentList)
        {
            try
            {
                string dir = HS_Path.GetDirectoryName(fileName);

                HS_Directory.CreateDirectory(dir);

                StreamWriter sw = new StreamWriter(fileName, false, Encoding.UTF8);
                for (int i = 0; i < contentList.Length; i++)
                {
                    sw.WriteLine(contentList[i]);
                    sw.Flush();
                }
                sw.Flush();
                sw.Close();
            }
            catch (Exception _e)
            {
                D.LogErrorForce(_e.StackTrace);
            }
        }