Пример #1
0
        /// <summary>
        /// Writes the data supplied to the csv.
        /// </summary>
        /// <param name="csvName">Name of the csv file.</param>
        /// <param name="data">The data to be written to the csv.</param>
        /// <returns>A boolean value.</returns>
        public bool WriteData(string csvName, string data)
        {
            var filePath = string.Concat(_csvBasePath, csvName);
            var success  = false;

            if (string.IsNullOrEmpty(csvName) || !_helper.FileExists(filePath))
            {
                return(success);
            }

            try
            {
                if (!string.IsNullOrEmpty(data))
                {
                    success = _helper.AppendDataTofile(filePath, data);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("Exception : ", ex);
                throw new Exception("Error Occurred. Please Try Again.");
            }

            return(success);
        }