开发者

How to read shared file from Ubuntu/Samba using C#?

开发者 https://www.devze.com 2023-03-09 01:51 出处:网络
I have shared folder on ubuntu/samba server of my network. I am running my c# code on Vista , so How can i read file shared on 开发者_高级运维ubuntu/samba server ?

I have shared folder on ubuntu/samba server of my network.

I am running my c# code on Vista , so How can i read file shared on 开发者_高级运维ubuntu/samba server ?

My code :

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";


If the share is configured properly you should be able to access it via \\ubuntumachine\sambasharename just as you would a Windows share.

0

精彩评论

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