दस्तावेज़ तुलना .net – पूर्ण GroupDocs कार्यान्वयन गाइड

यदि आपको compare documents .net की आवश्यकता है, तो आप सही जगह पर आए हैं। कल्पना करें कि दो अनुबंध खोल रहे हैं जो बिल्कुल समान दिखते हैं और तुरंत हर बदलाव को पहचान रहे हैं—कोई मैन्युअल स्क्रॉलिंग नहीं, कोई छूटा हुआ संपादन नहीं। यही स्वचालित दस्तावेज़ तुलना की शक्ति है, और GroupDocs.Comparison for .NET के साथ आप इसे मिनटों में कर सकते हैं।

त्वरित उत्तर

  • .NET में दस्तावेज़ तुलना को संभालने वाली लाइब्रेरी कौन सी है? GroupDocs.Comparison.
  • क्या मैं Word, Excel, और PDF फ़ाइलों की तुलना कर सकता हूँ? हाँ—50 से अधिक फ़ॉर्मैट समर्थित हैं।
  • कौन सा संस्करण उपयोग करना चाहिए? संस्करण 25.4.0 सबसे बेहतर प्रदर्शन और स्थिरता प्रदान करता है।
  • क्या उत्पादन के लिए लाइसेंस चाहिए? उत्पादन परिनियोजन के लिए एक वाणिज्यिक लाइसेंस आवश्यक है।
  • क्या async प्रोसेसिंग संभव है? बिल्कुल—तुलना API के साथ Task.Run का उपयोग करें।

GroupDocs.Comparison क्या है?

GroupDocs.Comparison एक .NET लाइब्रेरी है जो प्रोग्रामेटिक रूप से दो या अधिक दस्तावेज़ों के बीच अंतर का पता लगाती है और एक हाइलाइटेड परिणाम फ़ाइल बनाती है। यह 50+ फ़ॉर्मैट का समर्थन करती है, कई‑सौ‑पृष्ठ वाली फ़ाइलों को पूरी सामग्री को मेमोरी में लोड किए बिना प्रोसेस करती है, और तुलना सेटिंग्स पर सूक्ष्म नियंत्रण प्रदान करती है।

compare documents .net के लिए GroupDocs.Comparison क्यों उपयोग करें?

GroupDocs.Comparison .NET अनुप्रयोगों के लिए तेज़, सटीक और स्केलेबल दस्तावेज़ डिफ़िंग प्रदान करता है। यह बड़े PDF और Office फ़ाइलों को सेकंडों में प्रोसेस कर सकता है, फ़ॉर्मैटिंग और विज़ुअल फ़िडेलिटी को बनाए रखते हुए इंसर्शन, डिलीशन और स्टाइल परिवर्तन को हाइलाइट करता है। लाइब्रेरी .NET Core, .NET 5/6/7, और पूर्ण .NET Framework के साथ काम करती है, जिससे यह किसी भी प्रोजेक्ट के लिए बहुमुखी विकल्प बनती है।

  • गति: मानक सर्वर पर 200‑पेज PDF को 2 सेकंड से कम में प्रोसेस करता है।
  • सटीकता: टेक्स्ट, फ़ॉर्मैटिंग, टेबल और इमेज को 99.9 % फ़िडेलिटी के साथ पहचानता है।
  • स्केलेबिलिटी: स्ट्रीमिंग API का उपयोग करके हजारों फ़ाइलों के बैच जॉब्स को संभालता है।
  • लचीलापन: .NET Core 3.1+, .NET 5/6/7, और .NET Framework 4.6.1+ के साथ काम करता है।

पूर्वापेक्षाएँ

  • डेवलपमेंट एनवायरनमेंट: .NET Core 3.1 या नया, या .NET Framework 4.6.1 +
  • GroupDocs.Comparison लाइब्रेरी: संस्करण 25.4.0 (NuGet के माध्यम से इंस्टॉल)
  • सैंपल फ़ाइलें: परीक्षण के लिए Word, PDF, या Excel दस्तावेज़
  • बेसिक C# ज्ञान: क्लासेज, मेथड्स, using स्टेटमेंट्स

Nice‑to‑Have (Optional)

  • NuGet पैकेज मैनेजमेंट की परिचितता
  • फ़ाइल I/O और स्ट्रीम्स का अनुभव
  • async/await पैटर्न की समझ

GroupDocs.Comparison का उपयोग करके compare documents .net कैसे करें?

दो दस्तावेज़ों की तुलना करने के लिए, प्रत्येक फ़ाइल को एक स्ट्रीम में लोड करें, वैकल्पिक ComparisonSettings कॉन्फ़िगर करें, और Comparer इंस्टेंस पर Compare मेथड को कॉल करें। API एक परिणाम दस्तावेज़ लौटाता है जो अंतर को हाइलाइट करता है, और आप इसे किसी भी समर्थित फ़ॉर्मैट में सहेज सकते हैं। यह दृष्टिकोण केवल कुछ लाइनों के कोड की आवश्यकता रखता है जबकि तुलना प्रक्रिया पर पूर्ण नियंत्रण देता है।

चरण‑दर‑चरण कार्यान्वयन

1️⃣ स्मार्ट डॉक्यूमेंट पाथ मैनेजमेंट

फ़ाइल पाथ को केंद्रीकृत करने से “फ़ाइल नहीं मिली” त्रुटियों से बचा जा सकता है और पर्यावरण स्विच को आसान बनाया जा सकता है।

public static class Constants
{
    public const string SOURCE_WORD = @"YOUR_DOCUMENT_DIRECTORY\source.docx";
    public const string TARGET_WORD = @"YOUR_DOCUMENT_DIRECTORY\target.docx";

    public static string GetOutputDirectoryPath()
    {
        return @"YOUR_OUTPUT_DIRECTORY";
    }

    public const string RESULT_WORD = "result.docx";
}

यह क्यों काम करता है:

  • विकास, परीक्षण या उत्पादन के लिए पाथ को एक ही जगह अपडेट किया जा सकता है।
  • कोडबेस में बिखरे हुए हार्ड‑कोडेड स्ट्रिंग्स को समाप्त करता है।

2️⃣ कोर तुलना लॉजिक

Comparer क्लास वह इंजन है जो डिफ़ एल्गोरिद्म को चलाता है।

using (Comparer comparer = new Comparer(Constants.SOURCE_WORD))
{
    // Add the target document for comparison
    comparer.Add(Constants.TARGET_WORD);

    // Perform the comparison and save the result
    string outputFileName = Path.Combine(Constants.GetOutputDirectoryPath(), Constants.RESULT_WORD);
    comparer.Compare(outputFileName);
}

परिभाषा एंकर:
Comparer GroupDocs.Comparison की कोर क्लास है जो दस्तावेज़ विश्लेषण को ऑर्केस्ट्रेट करती है और हाइलाइटेड परिणाम उत्पन्न करती है।

यह कैसे मदद करता है:

  • Add() कॉल्स को दोहराकर कई टार्गेट दस्तावेज़ों का समर्थन करता है।
  • परिवर्तन को लाल, हरे या कस्टम रंगों में हाइलाइट करके परिणाम फ़ाइल बनाता है।

3️⃣ Excel और PDF के लिए उन्नत सेटिंग्स

आप तुलना को फ़ॉर्मैटिंग को अनदेखा करने या डेटा परिवर्तन पर फोकस करने के लिए फाइन‑ट्यून कर सकते हैं—compare excel files c# परिदृश्यों के लिए आदर्श।

CompareOptions compareOptions = new CompareOptions()
{
    ShowDeletedContent = true,
    ShowInsertedContent = true,
    StyleChangeDetection = true
};

using (Comparer comparer = new Comparer(sourcePath))
{
    comparer.Add(targetPath);
    comparer.Compare(outputPath, compareOptions);
}

परिभाषा एंकर:
ComparisonSettings आपको DetectStyleChanges या DetectTableChanges जैसे विशिष्ट परिवर्तन प्रकारों को सक्षम या अक्षम करने की अनुमति देता है।

4️⃣ कई फ़ॉर्मैट्स को संभालना

GroupDocs.Comparison स्वचालित रूप से फ़ाइल प्रकार का पता लगाता है, लेकिन आवश्यकता पड़ने पर आप फ़ॉर्मैट को भी फ़ोर्स कर सकते हैं—compare pdf files c# के लिए उपयुक्त।

public static void CompareDocumentsByType(string sourcePath, string targetPath, string outputPath)
{
    string extension = Path.GetExtension(sourcePath).ToLower();
    
    using (Comparer comparer = new Comparer(sourcePath))
    {
        comparer.Add(targetPath);
        
        CompareOptions options = GetOptionsForFormat(extension);
        comparer.Compare(outputPath, options);
    }
}

private static CompareOptions GetOptionsForFormat(string extension)
{
    switch (extension)
    {
        case ".pdf":
            return new CompareOptions { DetectStyleChanges = false };
        case ".xlsx":
            return new CompareOptions { CalculateCoordinates = true };
        default:
            return new CompareOptions();
    }
}

5️⃣ बड़े फ़ाइलों का स्ट्रीमिंग

जब विशाल दस्तावेज़ प्रोसेस कर रहे हों, तो स्ट्रीमिंग पूरी फ़ाइल को मेमोरी में लोड किए बिना बचाता है।

// For files over 50MB, consider this approach
using (var sourceStream = File.OpenRead(sourcePath))
using (var targetStream = File.OpenRead(targetPath))
using (var comparer = new Comparer(sourceStream))
{
    comparer.Add(targetStream);
    comparer.Compare(outputStream);
}

6️⃣ मजबूत एरर हैंडलिंग

कभी भी एक करप्ट फ़ाइल आपके सर्विस को क्रैश न करने दें; कॉल्स को try‑catch ब्लॉक्स में रैप करें और उपयोगी विवरण लॉग करें।

try
{
    using (Comparer comparer = new Comparer(sourcePath))
    {
        comparer.Add(targetPath);
        comparer.Compare(outputPath);
    }
}
catch (FileNotFoundException ex)
{
    Console.WriteLine($"Document not found: {ex.FileName}");
}
catch (UnauthorizedAccessException ex)
{
    Console.WriteLine($"Access denied: {ex.Message}");
}
catch (Exception ex)
{
    Console.WriteLine($"Comparison failed: {ex.Message}");
}

दस्तावेज़ तुलना सर्वश्रेष्ठ प्रथाएँ

  • API को कॉल करने से पहले इनपुट फ़ाइलों को वैध करें ताकि असमर्थित फ़ॉर्मैट जल्दी पकड़े जा सकें।
  • Path.Combine का उपयोग करके क्रॉस‑प्लेटफ़ॉर्म पाथ निर्माण करें (देखें Pitfall #1)।
  • केवल आवश्यक परिवर्तन प्रकारों को सक्षम करें ताकि प्रदर्शन सुधरे (उदा., डेटा‑सेंटरिक Excel शीट्स के लिए स्टाइल डिटेक्शन को डिसेबल करें)।
  • Comparer ऑब्जेक्ट्स को तुरंत डिस्पोज़ करें ताकि नेटिव रिसोर्सेज़ मुक्त हो सकें।

सामान्य समस्याएँ और समाधान

Pitfall #1: पाथ सेपरेटर समस्याएँ

समाधान: हमेशा Path.Combine() और Path.DirectorySeparatorChar के साथ पाथ बनाएं।

// Wrong - will break on different operating systems
string path = "C:/Documents/source.docx";

// Right - works everywhere
string path = Path.Combine("C:", "Documents", "source.docx");

Pitfall #2: बड़े फ़ाइलों पर मेमोरी समाप्ति

समाधान: 50 MB से बड़ी फ़ाइलों के लिए स्ट्रीमिंग मोड में स्विच करें।

// For files over 50MB, consider this approach
using (var sourceStream = File.OpenRead(sourcePath))
using (var targetStream = File.OpenRead(targetPath))
using (var comparer = new Comparer(sourceStream))
{
    comparer.Add(targetStream);
    comparer.Compare(outputStream);
}

Pitfall #3: एक्सेप्शन को अनदेखा करना

समाधान: व्यापक try‑catch ब्लॉक्स लागू करें और स्टैक ट्रेस लॉग करें।

try
{
    using (Comparer comparer = new Comparer(sourcePath))
    {
        comparer.Add(targetPath);
        comparer.Compare(outputPath);
    }
}
catch (FileNotFoundException ex)
{
    Console.WriteLine($"Document not found: {ex.FileName}");
}
catch (UnauthorizedAccessException ex)
{
    Console.WriteLine($"Access denied: {ex.Message}");
}
catch (Exception ex)
{
    Console.WriteLine($"Comparison failed: {ex.Message}");
}

प्रदर्शन अनुकूलन रणनीतियाँ

मेमोरी मैनेजमेंट

संभव हो तो Comparer इंस्टेंस को पुन: उपयोग करें और प्रत्येक तुलना के बाद Dispose() कॉल करें।

// Always dispose of resources properly
using (var comparer = new Comparer(sourcePath))
{
    comparer.Add(targetPath);
    comparer.Compare(outputPath);
    
    // Comparer is automatically disposed here
}

// For batch processing, clear resources between comparisons
for (int i = 0; i < documentPairs.Count; i++)
{
    using (var comparer = new Comparer(documentPairs[i].Source))
    {
        comparer.Add(documentPairs[i].Target);
        comparer.Compare(documentPairs[i].Output);
    }
    
    // Force garbage collection every 10 documents if needed
    if (i % 10 == 0)
    {
        GC.Collect();
        GC.WaitForPendingFinalizers();
    }
}

असिंक्रोनस प्रोसेसिंग

UI को रिस्पॉन्सिव रखने के लिए बैकग्राउंड थ्रेड्स पर तुलना चलाएँ।

public async Task<bool> CompareDocumentsAsync(string sourcePath, string targetPath, string outputPath)
{
    return await Task.Run(() =>
    {
        try
        {
            using (var comparer = new Comparer(sourcePath))
            {
                comparer.Add(targetPath);
                comparer.Compare(outputPath);
                return true;
            }
        }
        catch
        {
            return false;
        }
    });
}

लोकप्रिय .NET फ्रेमवर्क्स के साथ इंटीग्रेशन

ASP.NET Core Web API इंटीग्रेशन

एक REST एन्डपॉइंट एक्सपोज़ करें जो दो फ़ाइलें स्वीकार करता है और डिफ़ परिणाम लौटाता है।

[ApiController]
[Route("api/[controller]")]
public class DocumentComparisonController : ControllerBase
{
    [HttpPost("compare")]
    public async Task<IActionResult> CompareDocuments([FromForm] IFormFile sourceFile, [FromForm] IFormFile targetFile)
    {
        if (sourceFile == null || targetFile == null)
            return BadRequest("Both source and target files are required.");

        var tempFolder = Path.GetTempPath();
        var sourcePath = Path.Combine(tempFolder, sourceFile.FileName);
        var targetPath = Path.Combine(tempFolder, targetFile.FileName);
        var outputPath = Path.Combine(tempFolder, $"comparison_{Guid.NewGuid()}.pdf");

        try
        {
            // Save uploaded files
            using (var stream = new FileStream(sourcePath, FileMode.Create))
                await sourceFile.CopyToAsync(stream);
            
            using (var stream = new FileStream(targetPath, FileMode.Create))
                await targetFile.CopyToAsync(stream);

            // Perform comparison
            using (var comparer = new Comparer(sourcePath))
            {
                comparer.Add(targetPath);
                comparer.Compare(outputPath);
            }

            // Return the result file
            var fileBytes = await System.IO.File.ReadAllBytesAsync(outputPath);
            return File(fileBytes, "application/pdf", "comparison_result.pdf");
        }
        finally
        {
            // Clean up temp files
            File.Delete(sourcePath);
            File.Delete(targetPath);
            File.Delete(outputPath);
        }
    }
}

Blazor कंपोनेंट इंटीग्रेशन

एक पुन: उपयोग योग्य कंपोनेंट बनाएं जो ब्राउज़र में साइड‑बाय‑साइड तुलना दिखाता है।

@using GroupDocs.Comparison
@inject IJSRuntime JSRuntime

<div class="document-comparison">
    <InputFile OnChange="HandleFileSelection" multiple />
    <button @onclick="CompareDocuments" disabled="@(!CanCompare)">Compare Documents</button>
    
    @if (comparisonResult != null)
    {
        <div class="result">
            <a href="@comparisonResult" download="comparison_result.pdf">Download Result</a>
        </div>
    }
</div>

@code {
    private List<IBrowserFile> selectedFiles = new();
    private string comparisonResult;
    
    private bool CanCompare => selectedFiles.Count == 2;

    private async Task HandleFileSelection(InputFileChangeEventArgs e)
    {
        selectedFiles = e.GetMultipleFiles(2).ToList();
    }

    private async Task CompareDocuments()
    {
        if (selectedFiles.Count != 2) return;

        // Implementation similar to Web API example
        // Save files, compare, and generate result
    }
}

वास्तविक‑दुनिया उपयोग केस

परिदृश्य 1: कानूनी अनुबंध समीक्षा

कानूनी फर्में अनुबंध संशोधनों में जोड़, हटाव और फ़ॉर्मैटिंग परिवर्तन को स्वचालित रूप से हाइलाइट कर सकती हैं।

public class ContractReviewService
{
    public ContractComparisonResult ReviewContract(string originalContract, string revisedContract)
    {
        var outputPath = Path.Combine(Path.GetTempPath(), $"contract_review_{DateTime.Now:yyyyMMddHHmmss}.docx");
        
        var compareOptions = new CompareOptions
        {
            ShowDeletedContent = true,
            ShowInsertedContent = true,
            StyleChangeDetection = true,
            WordsSeparatorChars = new[] { ' ', '.', ',', '!', '?' }
        };

        using (var comparer = new Comparer(originalContract))
        {
            comparer.Add(revisedContract);
            comparer.Compare(outputPath, compareOptions);
        }

        return new ContractComparisonResult
        {
            OutputPath = outputPath,
            HasChanges = File.Exists(outputPath),
            ComparisonDate = DateTime.Now
        };
    }
}

परिदृश्य 2: स्प्रेडशीट्स के लिए संस्करण नियंत्रण

वित्तीय टीमें Excel मॉडल में बदलावों का पता बिना प्रत्येक फ़ाइल को मैन्युअली खोले लगा सकती हैं।

public class DocumentVersionControl
{
    public void TrackDocumentChanges(string documentPath, string repositoryPath)
    {
        var versions = Directory.GetFiles(repositoryPath, "*.docx").OrderBy(f => f);
        var latestVersion = versions.LastOrDefault();

        if (latestVersion != null)
        {
            var comparisonPath = Path.Combine(repositoryPath, $"changes_{DateTime.Now:yyyyMMdd}.docx");
            
            using (var comparer = new Comparer(latestVersion))
            {
                comparer.Add(documentPath);
                comparer.Compare(comparisonPath);
            }

            // Archive the comparison for future reference
            ArchiveComparison(comparisonPath);
        }
    }

    private void ArchiveComparison(string comparisonPath)
    {
        // Implementation for archiving comparison results
        var archivePath = Path.Combine(Path.GetDirectoryName(comparisonPath), "archive", Path.GetFileName(comparisonPath));
        Directory.CreateDirectory(Path.GetDirectoryName(archivePath));
        File.Move(comparisonPath, archivePath);
    }
}

ट्रबलशूटिंग गाइड

Issue 1: “File format not supported”

समाधान: फ़ाइल एक्सटेंशन को समर्थित सूची (50+ फ़ॉर्मैट) के विरुद्ध सत्यापित करें और असमर्थित प्रकारों को पहले PDF में बदलें।

private static readonly HashSet<string> SupportedFormats = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
    ".docx", ".doc", ".pdf", ".xlsx", ".xls", ".pptx", ".ppt", ".txt", ".rtf"
};

public static bool IsFormatSupported(string filePath)
{
    var extension = Path.GetExtension(filePath);
    return SupportedFormats.Contains(extension);
}

Issue 2: बड़े फ़ाइलों पर मेमोरी समस्याएँ

समाधान: स्ट्रीमिंग सक्षम करें और फ़ाइलों को चंक्स में प्रोसेस करें।

public static void CompareLargeDocuments(string sourcePath, string targetPath, string outputPath)
{
    var fileInfo = new FileInfo(sourcePath);
    
    if (fileInfo.Length > 50 * 1024 * 1024) // 50MB threshold
    {
        // Use streaming approach
        using (var sourceStream = File.OpenRead(sourcePath))
        using (var targetStream = File.OpenRead(targetPath))
        using (var outputStream = File.Create(outputPath))
        using (var comparer = new Comparer(sourceStream))
        {
            comparer.Add(targetStream);
            comparer.Compare(outputStream);
        }
    }
    else
    {
        // Standard approach for smaller files
        using (var comparer = new Comparer(sourcePath))
        {
            comparer.Add(targetPath);
            comparer.Compare(outputPath);
        }
    }
}

Issue 3: खाली तुलना परिणाम

समाधान: DetectFormattingChanges या DetectStyleChanges को टॉगल करके संवेदनशीलता बढ़ाएँ।

var compareOptions = new CompareOptions
{
    DetectStyleChanges = true,
    DiagramMasterSetting = new DiagramMasterSetting
    {
        UseSourceMaster = true,
        CloneSourceMaster = true
    },
    OriginalSize = new Size(600, 800),
    HeaderFootersComparison = true,
    PaperSize = PaperSize.A4
};

अक्सर पूछे जाने वाले प्रश्न

प्रश्न: एक साथ कितने दस्तावेज़ तुलना कर सकते हैं?
उत्तर: आप Comparer इंस्टेंस में कई टार्गेट दस्तावेज़ Add() कॉल्स से जोड़ सकते हैं, लेकिन बड़े बैच के लिए क्रमिक प्रोसेसिंग की सलाह दी जाती है।

प्रश्न: क्या GroupDocs.Comparison पासवर्ड‑प्रोटेक्टेड फ़ाइलों को संभाल सकता है?
उत्तर: हाँ—Comparer बनाते समय या दस्तावेज़ लोड करते समय पासवर्ड पास करें।

using (var comparer = new Comparer(sourcePath, new LoadOptions("password")))
{
    comparer.Add(targetPath, new LoadOptions("targetPassword"));
    comparer.Compare(outputPath);
}

प्रश्न: GroupDocs.Comparison किन फ़ाइल फ़ॉर्मैट्स को सपोर्ट करता है?
उत्तर: 50 से अधिक फ़ॉर्मैट, जिसमें DOCX, XLSX, PPTX, PDF, JPEG, PNG, TXT आदि शामिल हैं।

प्रश्न: परिवर्तन की उपस्थिति को कैसे कस्टमाइज़ करूँ?
उत्तर: ComparisonSettings का उपयोग करके InsertedColor, DeletedColor, और StyleChangeColor सेट करें।

var compareOptions = new CompareOptions
{
    InsertedItemStyle = new StyleSettings
    {
        HighlightColor = Color.Green,
        FontColor = Color.DarkGreen
    },
    DeletedItemStyle = new StyleSettings
    {
        HighlightColor = Color.Red,
        FontColor = Color.DarkRed
    }
};

प्रश्न: क्या विशिष्ट परिवर्तन प्रकारों को अनदेखा किया जा सकता है?
उत्तर: बिल्कुल—ComparisonSettings में DetectStyleChanges या DetectTableChanges जैसे विकल्पों को डिसेबल करें।

var compareOptions = new CompareOptions
{
    DetectStyleChanges = false, // Ignore formatting changes
    HeaderFootersComparison = false, // Skip headers/footers
    WordsSeparatorChars = new[] { ' ', '\n', '\r', '\t' } // Define word boundaries
};

प्रश्न: क्या मैं क्लाउड स्टोरेज में संग्रहीत दस्तावेज़ों की तुलना कर सकता हूँ?
उत्तर: हाँ—स्ट्रीम्स को स्थानीय रूप से डाउनलोड करें या सीधे MemoryStream से तुलना करें।

using (var sourceStream = await DownloadFromCloudAsync(sourceUrl))
using (var targetStream = await DownloadFromCloudAsync(targetUrl))
using (var comparer = new Comparer(sourceStream))
{
    comparer.Add(targetStream);
    comparer.Compare(outputStream);
}

प्रश्न: GroupDocs.Comparison को Docker कंटेनर में कैसे चलाएँ?
उत्तर: अपने Dockerfile में आवश्यक नेटिव डिपेंडेंसीज़ शामिल करें और लाइसेंस फ़ाइल को कंटेनर में कॉपी करें।

FROM mcr.microsoft.com/dotnet/aspnet:6.0
# Install necessary fonts and libraries for document processing
RUN apt-get update && apt-get install -y libfontconfig1 libfreetype6

प्रश्न: उत्पादन के लिए कौन सा लाइसेंस आवश्यक है?
उत्तर: उत्पादन परिनियोजन के लिए एक वाणिज्यिक GroupDocs.Comparison लाइसेंस अनिवार्य है। विकल्पों में डेवलपर, साइट, और OEM लाइसेंस शामिल हैं।

प्रश्न: तुलना विफलताओं को सुगमता से कैसे संभालें?
उत्तर: तुलना कॉल को try‑catch ब्लॉक में रैप करें, एक्सेप्शन लॉग करें, और उपयोगकर्ता‑मित्र त्रुटि संदेश लौटाएँ।

public async Task<ComparisonResult> CompareDocumentsWithRetry(string source, string target, int maxRetries = 3)
{
    for (int attempt = 1; attempt <= maxRetries; attempt++)
    {
        try
        {
            using (var comparer = new Comparer(source))
            {
                comparer.Add(target);
                var outputPath = GenerateOutputPath();
                comparer.Compare(outputPath);
                
                return new ComparisonResult { Success = true, OutputPath = outputPath };
            }
        }
        catch (Exception ex) when (attempt < maxRetries)
        {
            _logger.LogWarning($"Comparison attempt {attempt} failed: {ex.Message}. Retrying...");
            await Task.Delay(TimeSpan.FromSeconds(attempt * 2)); // Exponential backoff
        }
        catch (Exception ex)
        {
            _logger.LogError(ex, $"Comparison failed after {maxRetries} attempts");
            return new ComparisonResult { Success = false, Error = ex.Message };
        }
    }
    
    return new ComparisonResult { Success = false, Error = "Max retries exceeded" };
}

आवश्यक संसाधन और दस्तावेज़ीकरण


अंतिम अपडेट: 2026-06-10
परीक्षित संस्करण: GroupDocs.Comparison 25.4.0 for .NET
लेखक: GroupDocs

Install-Package GroupDocs.Comparison -Version 25.4.0
dotnet add package GroupDocs.Comparison --version 25.4.0
using GroupDocs.Comparison;

संबंधित ट्यूटोरियल्स