本文介绍了如何使用 C# 从 Ubuntu/Samba 读取共享文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在网络的 ubuntu/samba 服务器上有共享文件夹.
I have shared folder on ubuntu/samba server of my network.
我在 Vista 上运行我的 c# 代码,那么如何读取在 ubuntu/samba 服务器上共享的文件?
I am running my c# code on Vista , so How can i read file shared on ubuntu/samba server ?
我的代码:
String errorLogFile = @"\\\\198.168.0.2\\sharedfolder\myfile.wmv";
//throws excetion login fail
StreamReader sr = new StreamReader(errorLogFile);
sr.Read();
streamWriter.Close();
推荐答案
使用 此答案 用于验证远程目录的代码.
Use the code provided in this answer to authenticate your code for the remote directory.
更新:
此外,转义反斜杠和逐字字符串的组合是一个坏主意.使用其中之一,但不要同时使用.
此外,您在共享文件夹名称后缺少反斜杠.
应该是这样的:
Update:
Additionally, the combination of escaped backslashes and verbatim strings is a bad idea. Use one of these but not both.
Also, you are missing the backslash after the name of the shared folder.
It should be like this:
String errorLogFile = @"\\198.168.0.2\sharedfolder\" + finaldate + ".wmv";
这篇关于如何使用 C# 从 Ubuntu/Samba 读取共享文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!