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??


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 May 15 '13 at 13:31
  • Here they are finding checksum value for string. How can i find for a document? – Suren May 16 '13 at 4:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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