How to validate a RAR file in C# .Net Framework

Cloudmersive
1 min readAug 1, 2020

--

To save yourself a whole ton of headaches later on, today’s post is going to demonstrate how to quickly set up RAR archive validation. In just two simple steps, you will be all set with full validation capabilities. Let’s begin.

First we are going to install our library using this package manager console command.

Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 3.2.8

Next step: call our function. Use the below code snippet as a basis for your implementation.

using System;using System.Diagnostics;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Api;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Client;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Model;namespace Example{public class ValidateDocumentRarValidationExample{public void main(){// Configure API key authorization: ApikeyConfiguration.Default.AddApiKey("Apikey", "YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new ValidateDocumentApi();var inputFile = new System.IO.Stream(); // System.IO.Stream | Input file to perform the operation on.try{// Validate a RAR Archive file (RAR)DocumentValidationResult result = apiInstance.ValidateDocumentRarValidation(inputFile);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling ValidateDocumentApi.ValidateDocumentRarValidation: " + e.Message );}}}}

And that’s all there is to it! If you have other file validation needs, this library has numerous related functions covering everything from GZIPs to DOCX files.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet