コード例 #1
0
        /// <summary>
        /// Writes a DataTable to a CSV file specified by the path
        /// </summary>
        /// <param name="dataTable">The datatable to write</param>
        /// <param name="filePath">The location of the CSV to create</param>
        /// <param name="settings">Optional csv settings</param>
        public static void ToCsv(this DataTable dataTable, string filePath, ToCsvSettings settings = null)
        {
            settings = settings ?? new ToCsvSettings();

            using (IFileWriter fileWriter = FileWriterFactory.GetFileWriter(filePath, settings.Compression))
            {
                fileWriter.Write(dataTable.ToCsv(settings));
            }
        }
コード例 #2
0
        public void Init()
        {
            Test1Path            = ResolveToCurrentDirectory("/js/test1.js");
            Test2Path            = ResolveToCurrentDirectory("/js/test2.js");
            EmbeddedResourcePath = ResolveToCurrentDirectory("/js/embedded.js");
            TestUnderscoresPath  = ResolveToCurrentDirectory("/js/test_underscores.js");
            string[] pathsToNormalize = { Test1Path, Test2Path, TestUnderscoresPath };
            foreach (var path in pathsToNormalize)
            {
                string content;
                using (var fileReader = fileReaderFactory.GetFileReader(path))
                {
                    content = TestUtilities.NormalizeLineEndings(fileReader.ReadToEnd());
                }

                using (var fileWriter = fileWriterFactory.GetFileWriter(path))
                {
                    fileWriter.Write(content);
                }
            }

            Directory.CreateDirectory(FilePath + TestUtilities.PreparePath(@"\js"));
        }