
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
FileConversionLibrary
Advanced tools
FileConversionLibrary is a .NET library for converting files between different formats. It supports converting CSV files to XML, PDF, Word, JSON, and YAML formats, as well as converting XML files to CSV, PDF, Word, JSON, and YAML formats. The library provides asynchronous methods for all conversions and includes comprehensive error handling.
A powerful .NET library for converting CSV and XML files to various formats including XML, PDF, Word, JSON, and YAML. Now with enhanced Stream API and In-Memory conversion capabilities!
// Create a new instance of the FileConverter
var fileConverter = new FileConverter();
// Convert CSV to PDF
await fileConverter.ConvertCsvToPdfAsync(
@"C:\Users\User\Desktop\csv_input.csv",
@"C:\Users\User\Desktop\output1.pdf"
);
// Convert CSV to JSON
await fileConverter.ConvertCsvToJsonAsync(
@"C:\Users\User\Desktop\csv_input.csv",
@"C:\Users\User\Desktop\output1.json"
);
// Convert CSV to Word
await fileConverter.ConvertCsvToWordAsync(
@"C:\Users\User\Desktop\csv_input.csv",
@"C:\Users\User\Desktop\output1.docx"
);
// Convert CSV to XML
await fileConverter.ConvertCsvToXmlAsync(
@"C:\Users\User\Desktop\csv_input.csv",
@"C:\Users\User\Desktop\output1.xml");
// Convert CSV to YAML
await fileConverter.ConvertCsvToYamlAsync(
@"C:\Users\User\Desktop\csv_input.csv",
@"C:\Users\User\Desktop\output1.yaml"
);
// Convert XML to CSV
await fileConverter.ConvertXmlToCsvAsync(
@"C:\Users\User\Desktop\xml_input.xml",
@"C:\Users\User\Desktop\output2.csv"
);
// Convert XML to JSON
await fileConverter.ConvertXmlToJsonAsync(
@"C:\Users\User\Desktop\xml_input.xml",
@"C:\Users\User\Desktop\output2.json"
);
// Convert XML to PDF
await fileConverter.ConvertXmlToPdfAsync(
@"C:\Users\User\Desktop\xml_input.xml",
@"C:\Users\User\Desktop\output2.pdf"
);
// Convert XML to Word
await fileConverter.ConvertXmlToWordAsync(
@"C:\Users\User\Desktop\xml_input.xml",
@"C:\Users\User\Desktop\output2.docx"
);
// Convert XML to YAML
await fileConverter.ConvertXmlToYamlAsync(
@"C:\Users\User\Desktop\xml_input.xml",
@"C:\Users\User\Desktop\output2.yaml"
);
For web applications, cloud services, and scenarios where you work with streams:
var fileConverter = new FileConverter();
// Convert from stream to stream
using var inputStream = File.OpenRead("input.csv");
var options = new ConversionOptions
{
SourceFormat = "csv",
TargetFormat = "json"
};
using var outputStream = await fileConverter.ConvertStreamAsync(inputStream, options);
// Convert stream to bytes (for HTTP responses)
var pdfBytes = await fileConverter.ConvertStreamToBytesAsync(inputStream, new ConversionOptions
{
SourceFormat = "csv",
TargetFormat = "pdf"
});
// Convert stream to string
var jsonString = await fileConverter.ConvertStreamToStringAsync(inputStream, new ConversionOptions
{
SourceFormat = "csv",
TargetFormat = "json"
});
[HttpPost("convert")]
public async Task<IActionResult> ConvertFile(IFormFile file, string targetFormat)
{
var options = new ConversionOptions
{
SourceFormat = "csv",
TargetFormat = targetFormat
};
using var inputStream = file.OpenReadStream();
var result = await fileConverter.ConvertStreamToBytesAsync(inputStream, options);
return File(result, GetMimeType(targetFormat), $"converted.{targetFormat}");
}
Work directly with data objects for maximum performance and flexibility:
var fileConverter = new FileConverter();
// Create CSV data in memory
{
Headers = new[] { "Name", "Age", "City" },
Rows = new List<string[]>
{
new[] { "John Doe", "25", "New York" },
new[] { "Jane Smith", "30", "London" }
}
};
// Convert to different formats with advanced options
var jsonOptions = new JsonConversionOptions
{
ConvertValues = true,
UseIndentation = true,
IncludeRowNumbers = true,
CreateNestedObjects = true,
NestedSeparator = ".",
ConvertArrays = true,
ArrayDelimiter = ";"
};
var json = fileConverter.ConvertCsvToJson(csvData, jsonOptions);
var pdfOptions = new PdfConversionOptions
{
FontSize = 12f,
Title = "Sales Report",
IncludeTimestamp = true,
AlternateRowColors = true,
LandscapeOrientation = true,
FontFamily = "Arial"
};
var pdfBytes = fileConverter.ConvertCsvToPdf(csvData, pdfOptions);
var wordOptions = new WordConversionOptions
{
UseTable = true,
FontFamily = "Calibri",
FontSize = 11,
AlternateRowColors = true,
PageOrientation = "Landscape"
};
var wordBytes = fileConverter.ConvertCsvToWord(csvData, wordOptions);
var xmlOptions = new XmlConversionOptions
{
OutputFormat = "Elements",
UseCData = true,
IncludeTimestamp = true,
NamingConvention = "CamelCase",
AddComments = true
};
var xml = fileConverter.ConvertCsvToXml(csvData, xmlOptions);
var yamlOptions = new YamlConversionOptions
{
Structure = "Dictionary",
NamingConvention = "CamelCase",
ConvertDataTypes = true,
IncludeComments = true,
SortKeys = true
};
var yaml = fileConverter.ConvertCsvToYaml(csvData, yamlOptions);
// Create XML data in memory
var xmlContent = @"<?xml version=""1.0"" encoding=""UTF-8""?>
<products>
<product>
<Product>Laptop</Product>
<Price>999.99</Price>
<Category>Electronics</Category>
</product>
<product>
<Product>Book</Product>
<Price>29.99</Price>
<Category>Education</Category>
</product>
</products>";
var xmlData = new XmlData
{
Document = XDocument.Parse(xmlContent),
RootElementName = "products",
XmlVersion = "1.0",
Encoding = "UTF-8"
};
// Convert to different formats with advanced options
var csvOptions = new CsvConversionOptions
{
Delimiter = ';',
IncludeHeaders = true,
QuoteValues = true,
FlattenHierarchy = true,
IncludeAttributes = true
};
var csv = fileConverter.ConvertXmlToCsv(xmlData, csvOptions);
var jsonOptions = new JsonConversionOptions
{
ConvertValues = true,
UseIndentation = true,
RemoveWhitespace = true
};
var json = fileConverter.ConvertXmlToJson(xmlData, jsonOptions);
var pdfOptions = new PdfConversionOptions
{
Title = "Product Catalog",
FontSize = 10f,
AlternateRowColors = true,
IncludeTimestamp = true,
HierarchicalView = true
};
var pdf = fileConverter.ConvertXmlToPdf(xmlData, pdfOptions);
var wordOptions = new WordConversionOptions
{
UseTable = true,
FontFamily = "Calibri",
FontSize = 11,
FormatAsHierarchy = true,
AlternateRowColors = true
};
var word = fileConverter.ConvertXmlToWord(xmlData, wordOptions);
var yamlOptions = new YamlConversionOptions
{
Structure = "Dictionary",
ConvertDataTypes = true,
IncludeRootElement = true,
IncludeAttributes = true,
UseCamelCase = false,
SortKeys = true
};
var yaml = fileConverter.ConvertXmlToYaml(xmlData, yamlOptions);
// ASP.NET Core file upload and conversion
[HttpPost("upload-convert")]
public async Task<IActionResult> UploadAndConvert(IFormFile file)
{
using var stream = file.OpenReadStream();
var options = new ConversionOptions { SourceFormat = "csv", TargetFormat = "pdf" };
var result = await fileConverter.ConvertStreamToBytesAsync(stream, options);
return File(result, "application/pdf", "report.pdf");
}
// Convert data received from another service
public async Task<string> ProcessDataFromService(HttpResponseMessage response)
{
using var stream = await response.Content.ReadAsStreamAsync();
var options = new ConversionOptions { SourceFormat = "xml", TargetFormat = "json" };
return await fileConverter.ConvertStreamToStringAsync(stream, options);
}
// Process data in memory without file I/O
public byte[] GenerateReport(List<DataRecord> records)
{
var csvData = new CsvData
{
Headers = new[] { "ID", "Name", "Value" },
Rows = records.Select(r => new[] { r.Id, r.Name, r.Value.ToString() }).ToList()
};
return fileConverter.ConvertCsvToPdf(csvData, new PdfConversionOptions
{
Title = "Data Report",
IncludeTimestamp = true
});
}
ConvertValues
: Auto-detect and convert data typesUseIndentation
: Pretty-print JSON outputIncludeRowNumbers
: Add row numbers to outputGroupByColumn
: Group data by specific columnCreateNestedObjects
: Support for nested object structuresConvertArrays
: Convert delimited values to arraysFontSize
: Text font sizeTitle
: Document titleAlternateRowColors
: Zebra-striped rowsLandscapeOrientation
: Page orientationIncludeTimestamp
: Add generation timestampUseTable
: Format as table vs. paragraphsFontFamily
& FontSize
: Typography settingsFormatAsHierarchy
: Hierarchical data representationAlternateRowColors
: Row stylingOutputFormat
: Elements, Attributes, Mixed, or HierarchicalUseCData
: Wrap content in CDATA sectionsNamingConvention
: Original, CamelCase, PascalCase, or SnakeCaseIncludeMetadata
: Add conversion metadataStructure
: Array, Dictionary, Hierarchical, or GroupedConvertDataTypes
: Auto-detect data typesSortKeys
: Alphabetically sort keysIncludeComments
: Add descriptive commentsContributions are welcome! Please feel free to submit a Pull Request.
Bohdan Harabadzhyu
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
FileConversionLibrary is a .NET library for converting files between different formats. It supports converting CSV files to XML, PDF, Word, JSON, and YAML formats, as well as converting XML files to CSV, PDF, Word, JSON, and YAML formats. The library provides asynchronous methods for all conversions and includes comprehensive error handling.
We found that fileconversionlibrary demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.