使用DirectoryInfo访问网络驱动器

时间:2015-02-22 17:14:08

标签: c# mono raspberry-pi

我正在使用c#和mono在Raspberry Pi上创建一个应用程序。当它使用DirectoryInfo并将其设置为网络路径时,它会在路径前添加home / pi /。我该如何防止这种情况?

        DirectoryInfo di = new DirectoryInfo(@"//192.168.1.13/Volume_2/Folder");

        Console.Write("File: " + di.FullName+ ": ");
        Console.WriteLine(di.Exists);

1 个答案:

答案 0 :(得分:0)

我不相信你想要做的事情会以这种方式运作。 原因是SMB连接通常是我管理操作系统而不是C#。同样在Windows中,它将尝试以运行该进程的用户身份向远程服务器进行身份验证。在Linux上,本地用户不是域用户。

我认为更简单的解决方案是在Linux操作系统中映射网络驱动器,然后通过它的安装路径使用网络共享。

显然它可能略有不同,具体取决于您使用的Linux版本,但您最有可能使用Debian Wheezy,因为Ubuntu基于Debian,所以它应该与下面的文章非常相似。

https://wiki.ubuntu.com/MountWindowsSharesPermanently

相关问题