How to read shared file from Ubuntu/Samba using C#?
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.
精彩评论