Classic error readdir: pDirent->d_nameis the name of the entry in the directory, not the path to the file. This "1", "4-5.c"etc. So your calls statare looking for a file with that name in the current directory, not under MyDirectory.
stat. , ENOENT - . .., . stat , stat undefined.
opendir , ., , - , . , opendir, . ( ..):
char *directory = "MyDirectory";
size_t directory_length = strlen(directory);
char *path = malloc(directory_length + 1 + NAME_MAX);
strcpy(path, directory);
path[directory_length] = '/';
while ((pDirent = readdir(pDir)) != NULL) {
strcpy(path + directory_length + 1, pDirent->d_name);
if (stat(path, &vStat) == -1) {
perror(path);
continue;
}
…
}