Free Support Forum - groupdocs.com

System.ObjectDisposedException: Cannot access a closed Stream

Hi im receiving this error System.ObjectDisposedException: Cannot access a closed Stream. with following code:

compare(“csv/develop1.csv”, “csv/production1.csv”, “csv/result1.csv”);
compare(“csv/develop2.csv”, “csv/production2.csv”, “csv/result2.csv”);
compare(“csv/develop3.csv”, “csv/production3.csv”, “csv/result3.csv”);
compare(“csv/develop4.csv”, “csv/production4.csv”, “csv/result4.csv”);
compare(“csv/develop5.csv”, “csv/production5.csv”, “csv/result5.csv”);
compare(“csv/develop6.csv”, “csv/production6.csv”, “csv/result6.csv”);

    public static void compare(string sourcePath, string targetPath, string resultPath)
    {
        Comparer comparer = new Comparer(sourcePath);

        comparer.Add(targetPath);

        comparer.Compare();
        ChangeInfo[] changes = comparer.GetChanges();
        if (changes.Length > 0)
        {
            isChanged = true;
            comparer.Compare(resultPath);
        }
    }

@nikitozegg

We couldn’t reproduce this issue at our end using the provided code. Can you please share the problematic files with us? Also specify the API version that you are using.

the issue was fixed. here is my code:

///


/// Сompare files (csv, pdf, doc)
///

/// Source file
/// Target file
/// File with diff
public static void compare(string sourcePath, string targetPath, string resultPath)
{
        Comparer comparer = new Comparer(sourcePath);
      
            comparer.Add(targetPath);
            comparer.Compare();
            ChangeInfo[] changes = comparer.GetChanges();

            if (changes.Length > 0)
            {
                diffList.Add(resultPath);
                isChanged = true;
                comparer = new Comparer(sourcePath);
                comparer.Add(targetPath);
                comparer.Compare(resultPath);
            }

                 
    }
1 Like

@nikitozegg

Good to know that.