Question

I'm new in C/C++ and I need to retrieve images from a shared folder place in another computer for processing. How can I do that? Can someone please provide me some guidance or sample codes on how to do it? Besides, can I also get the list of files in a folder in the shared folder?

Was it helpful?

Solution

Open a file for reading:

char* filename = "//machine/shared/image.jpg";
FILE* f = fopen(filename, "r");

Read a directory:

struct dirent* ent;
char* path = "//machine/shared";

DIR* d = opendir(path);
while((ent = readdir(d)) != NULL)
{
    printf("%s\n", ent->d_name);
}

OTHER TIPS

Assuming you are on Windows, you can use a UNC path to refer to the file and use normal C/C++ IO (fopen or fstream). Just be sure to escape it correctly as part of the C string.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top