I am migrating data into SharePoint Document Library using web service. Here i need to check whether folder/document already exists before creating and have to verify the data using checksum. I checked folder/document exists already using Lists.asmx. How to use checksum here??

1 Answer 1


You can create an eventHandler, calculating checksum. Code for checksum is below.

private string CalculateChecksum(string fileUrlString)
        byte[] byteToCalculate = ReadAllBytes(fileUrlString);
        int checksum = 0;
        foreach (byte chData in byteToCalculate)
            checksum += chData;
        checksum &= 0xff;
        return checksum.ToString("X2");

 public static byte[] ReadAllBytes(string path)
byte[] bytes;
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
int index = 0;
long fileLength = fs.Length;
if (fileLength > Int32.MaxValue)
throw new IOException(“File too long”);
int count = (int)fileLength;
bytes = new byte[count];
while (count > 0)
int n = fs.Read(bytes, index, count);
if (n == 0)
throw new InvalidOperationException(“End of file reached before expected”);
index += n;
count -= n;
return bytes;
  • What input i should give in my case..?
    – Suren
    Commented May 15, 2013 at 13:31
  • Here they are finding checksum value for string. How can i find for a document?
    – Suren
    Commented May 16, 2013 at 4:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.