コード例 #1
0
        bool SaveCSV(string fileName, StringBuilder data)
        {
            if (fileName == string.Empty || (data == null || data.Length == 0))
            {
                return(false);
            }

            //var fp = new FileProcess();
            bool bCreate = FileProcess.CreateFolder(folderPath);

            //fp = null;

            if (bCreate == false)
            {
                TRMessageBox.Show(string.Format("Create CSV folder failed({0})", folderPath));
                return(false);
            }

            string filePath = string.Format("{0}\\{1}", folderPath, fileName);
            var    file     = new StreamWriter(filePath, true);

            try
            {
                file.Write(data.ToString());
                file.Flush();
                file.Close();
            }
            catch (Exception ee)
            {
                Log4.PrinterLogger.InfoFormat(ee.ToString());
                return(false);
            }

            return(true);
        }