【问题标题】:C opendir by HostnameC opendir 按主机名
【发布时间】:2015-07-28 10:12:48
【问题描述】:

我尝试将共享目录打开到另一台计算机。 这是我使用的代码。

#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>

int main()
{
    DIR * rep = NULL;

    rep = opendir("\\\\MYCOMPUTER");
    if(rep==NULL)
        perror("");
    else{
        printf("enfin !");
    }
    return 0;
}

我不知道为什么我得到了没有文件目录的错误。 当我尝试通过我的资源管理器打开我的直接时,它工作正常。我使用 \\MYCOMPUTER 打开它。

你有什么想法吗?

谢谢你:)

【问题讨论】:

标签: c opendir


【解决方案1】:

你在这里使用UNC syntax。我现在无法对其进行测试,但我假设 ...因为所有 UNC 路径都被定义为以下形式:

\\host\shared_folder\resource

一个简单的

\\host

不符合目录的条件。该代码可能适用于

\\host\shared_folder

所以,如果你想枚举 Windows 网络服务器上的所有共享文件夹,你可能不得不求助于native win32 API

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-29
    • 1970-01-01
    • 1970-01-01
    • 2020-03-11
    • 2014-08-23
    相关资源
    最近更新 更多