Exemplo n.º 1
0
        /// <summary>
        /// Build the file and write to disk.
        /// </summary>
        /// <returns>Filename of the file including the path.</returns>
        public string Build()
        {
            FullFileName = Path.Combine(GetPath(), fileMetaData.FileName);
            if (!string.IsNullOrWhiteSpace(existingFile))
            {
                File.Copy(existingFile, FullFileName);
                return(FullFileName);
            }

            using (var stream = new FileStream(FullFileName, FileMode.Create))
            {
                using (var writer = new StreamWriter(stream, fileMetaData.Encoding))
                {
                    var rowBuilder = new RowBuilder(fileMetaData);
                    writer.NewLine = fileMetaData.LinesTerminatedBy;
                    if (fileMetaData.HeaderRowCount > 0)
                    {
                        AddHeader(writer);
                    }
                    foreach (var line in row(rowBuilder))
                    {
                        writer.WriteLine(line);
                    }
                }
            }
            return(FullFileName);
        }
Exemplo n.º 2
0
        private FileBuilder AddHeader(TextWriter writer)
        {
            var rowBuilder = new RowBuilder(fileMetaData);

            foreach (var field in fileMetaData.Fields)
            {
                rowBuilder.AddField(Terms.Terms.ShortName(field.Term));
            }
            rowBuilder.Build();
            return(this);
        }