开发者

how to access a shared folder in another machine using C language

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 开发者_JS百科to do it? Besides, can I also get the list of files in a folder in the shared folder?


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);
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜