简体   繁体   English

从Windows系统写入具有Samba服务器的Linux系统中存在的文件

[英]Write to a file present in Linux system having a Samba server from a windows system

I need to write to a file present in Linux system having a Samba server from a windows system through C# code. 我需要通过C#代码写入一个存在于Linux系统中的文件,该文件具有来自Windows系统的Samba服务器。 I am just in the stating phase of evaluation, so I don't have a linux system with samba server now to test my code. 我刚刚进入评估的阶段,所以我现在没有带有samba服务器的linux系统来测试我的代码。 I found 2 useful links which fits my scenario very much. 我找到了两个非常适合我的场景的有用链接。 http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/03bf0cf2-be80-43a4-870c-83727dee1c63 and How to read shared file from Ubuntu/Samba using C#? http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/03bf0cf2-be80-43a4-870c-83727dee1c63以及如何使用C#从Ubuntu / Samba读取共享文件?

Now my problem is : My C# application is not fixed at particular system. 现在我的问题是:我的C#应用​​程序没有在特定系统上修复。 Its a desktop application which can be present in any system across domains. 它是一个桌面应用程序,可以存在于跨域的任何系统中。 Do I need to pass 2 username/passwords ? 我需要传递2个用户名/密码吗? 1 for unix system and 1 for windows(client) system? 1用于unix系统,1用于windows(客户端)系统? How do I do that through code? 我如何通过代码完成此操作?

If it is possible for you to configure your Linux as you like, then you can configure the SAMBA share so that it doesn't need a username or password at all. 如果您可以根据需要配置Linux,则可以配置SAMBA共享,使其根本不需要用户名或密码。 This has the drawback that anyone in the network can write and read your files. 这样做的缺点是网络中的任何人都可以写入和读取您的文件。

If you use the UNC path of the samba share (eg \\\\IP-address\\sharename) than you don't need to do anything special you can use the normal c# file system functions to access files by the UNC path. 如果使用samba共享的UNC路径(例如\\\\ IP-address \\ sharename)而不需要执行任何特殊操作,则可以使用常规c#文件系统函数通过UNC路径访问文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM