Archived Forum Post

Index of archived forum posts

Question:

Problem with Chilkat.FileAccess SplitFile

Feb 27 '14 at 12:43

I have a current support contract for Chilkat.

I am using code based on: http://www.example-code.com/csharp/facSplitFile.asp

I modified it slightly as follows so it uses my filename:

        Chilkat.FileAccess fac = new Chilkat.FileAccess();

        bool success;

        //  Any type of file may be split.  It doesn't matter if it's
        //  a binary file or a text file.
        string fileToSplit;
        fileToSplit = @"D:\ChilkatTest\Snap10.png";

        string partPrefix;
        partPrefix = "hamlet";
        string partExtension;
        partExtension = "spl";
        int maxChunkSize;
        maxChunkSize = 50000;
        string destDirPath;
        destDirPath = @"D:\ChilkatTest\";

        fac.VerboseLogging = true;

        //This will return true so I know the file is being found by Chilkat

        success = fac.FileExists(fileToSplit);

        if (success == true)
        {
            MessageBox.Show("Success.");
        }
        else
        {
            MessageBox.Show(fac.LastErrorText);
            Console.WriteLine(fac.LastErrorText);
        }

        //  Splits hamlet.xml into hamlet1.spl, hamlet2.spl, ...
        //  Output files are written to the current working directory.
        //  Each chunk will be 50000 bytes except for the last which
        //  will be the remainder.
        success = fac.SplitFile(fileToSplit, partPrefix, partExtension, maxChunkSize, destDirPath);

        if (success == true)
        {
            MessageBox.Show("Success.");
        }
        else
        {
            MessageBox.Show(fac.LastErrorText);
        }
    }

But I am getting this error which does not really tell me why it failed:

ChilkatLog:
  SplitFile:
    DllDate: Jan 16 2014
    ChilkatVersion: 9.5.0.5
    UnlockPrefix: NONE
    Username: OS-IT:OS-IT
    Architecture: Little Endian; 32-bit
    Language: .NET 2.0
    VerboseLogging: 1
    path: D:\ChilkatTest\Snap10.png
    prefix: hamlet
    extension: spl
    partSize: 50000
    bufSize: 200000
    Failed.
  --SplitFile

My Snap10.png file is located in the D:ChilkatTest directory and it is 15.5k. I even lowered the maxChunkSize to 5000 but it still errors out.

I have also tried this with other files and larger ones but the same error occurs.

Can you tell me what is causing this problem?


Answer

Thanks, I'm investigating...


Answer

This build should fix it:

32-bit: http://www.chilkatsoft.com/preRelease/ChilkatDotNet2-9.5.0-win32.zip

64-bit: http://www.chilkatsoft.com/preRelease/ChilkatDotNet2-9.5.0-x64.zip


Answer

Thanks Matt for the great support and fast turn around on the fix.

I will test this out.


Answer

The ability to file split works great. Thanks for fixing that.

However, when I go to reassemble the file using this example:

http://www.example-code.com/csharp/facReassembleFile.asp



Chilkat reports success, but the reassembled file has a file size of 0.

Here is the output of LastErrorText:

ChilkatLog:
  ReassembleFile:
    DllDate: Feb 24 2014
    ChilkatVersion: 9.5.0.14
    UnlockPrefix: NONE
    Username: OANDS-IT:O&S-IT
    Architecture: Little Endian; 32-bit
    Language: .NET 2.0
    VerboseLogging: 1
    Failed to open file (2)
    localFilePath: .\Snap101.spl
    currentWorkingDirectory: C:\Users\O&S-IT\Desktop\ChilkatSplit\ChilkatSplit\ChilkatSplit\bin\Debug
    osErrorInfo: The system cannot find the file specified.
    localWindowsFilePath: .\Snap101.spl
    Failed to open file data source.
    Success.
  --ReassembleFile
--ChilkatLog



I noticed it says there is a path problem, but Chilkat still reports success when this line of code is executed:

 success = fac.ReassembleFile(srcDirPath, partPrefix, partExtension, reassembledFilename);


Here is my code for reassembling the file:

    Chilkat.FileAccess fac = new Chilkat.FileAccess();

    bool success;

    //  Any type of file may be reassembled.  It doesn't matter if it's
    //  a binary file or a text file.
    string reassembledFilename;
    reassembledFilename = @"D:\ChilkatTest\2ASArchive4";

    string partPrefix;
    partPrefix = "Snap10";
    string partExtension;
    partExtension = "spl";
    string srcDirPath;
    srcDirPath = ".";
    fac.VerboseLogging = true;

    //  Reassembles the original file from hamlet1.spl, hamlet2.spl, ...
    success = fac.ReassembleFile(srcDirPath, partPrefix, partExtension, reassembledFilename);

    if (success == true)
    {
        MessageBox.Show("Success.");
    }
    else
    {
        MessageBox.Show(fac.LastErrorText);
    }

        MessageBox.Show(fac.LastErrorText);

Answer

The reason it reports success is that it will assemble parts until it fails on the next index. In this case, it failed on the 1st index (the 1st part) and in this special case it should return false. I made the fix and will provide an update later today..


Answer

I re-uploaded with the fix for ReassembleFile:

32-bit: http://www.chilkatsoft.com/preRelease/ChilkatDotNet2-9.5.0-win32.zip

64-bit: http://www.chilkatsoft.com/preRelease/ChilkatDotNet2-9.5.0-x64.zip