How you are doing that, easiest way is to use VSTA code, create an instance of your doc lib,
splist doclib = (spdocumentlibrary)web.lists["yourlistname];
splistitemcollection itemcoll = doclib.items;
int itemcount = itemcoll.count;
Let me now if you have some queries..