Problems when i change path for listing files
<p>I am trying to get all the files from a folder with their size. The problem is that i change the path from current directory, it can't find the size of files. It works only for the current directory, for the directory where is situated the project. If i wirte d=opendir(".") is working, but only like that and i want to change the path. Thanks
The code:</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;dirent.h&gt;
#include &lt;sys/stat.h&gt;

void main()
{
    DIR *d;
    struct dirent *de;
    struct stat buf;
    int exists;
    int total_size;

    d = opendir("C:\\MinGWStudio\\Templates");
    if (d == NULL) {
        perror("prsize");
        exit(1);
    }

    total_size = 0;

    for (de = readdir(d); de != NULL; de = readdir(d)) {
        exists = stat(de-&gt;d_name, &amp;buf);
        if (exists &lt; 0) {
            fprintf(stderr, "Couldn't stat %s\n", de-&gt;d_name);
        }
        else {
            printf("%s ", de-&gt;d_name);
            printf("%d \n", buf.st_size);
            total_size += buf.st_size;
        }
    }
    closedir(d);
    printf("%d\n", total_size);
}
</code></pre>