访问其他计算机上的共享文件夹 [英] Access to a shared folder on other computer

查看:305
本文介绍了访问其他计算机上的共享文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以给我发送一个示例,说明如何将文件从远程文件夹复制到其他远程文件夹吗?例如:我在MyComputer上运行MyProgram,此程序必须从OtherComputer内的文件夹中复制文件.此文件夹需要用户名和密码,以允许MyProgram复制文件.
我正在使用以下示例.此示例中的要点是使我的程序在linux和Windows中都可以运行,但可以在本地运行.现在,我想对这样的路径执行相同的操作:\\ 192.168.x.x \ mySharedFolder \ fileToBeCopied.text.也许我需要另一个图书馆,但我不知道.我想象有一种方法可以设置用户,密码甚至代理,以从共享文件夹中的其他计算机获取文件.


Can someone send me a example of how to copy a file from a remote folder to other remote folder? For example: I am running MyProgram on MyComputer and this program has to copy a file from a folder inside OtherComputer. This folder need user and password to allow MyProgram to copy the file.
I am using the following sample. The main point in this example is to make my program to work both in linux and windows, but locally. Now I want to do the same with a path like this: \\192.168.x.x\mySharedFolder\fileToBeCopied.text . Maybe I need another library but I don''t know. I imagine that there will be a way to set user, password and even proxy to get a file from other computer inside a shared folder.


//***http://www.ibm.com/developerworks/aix/library/au-boostfs/
#include <stdio.h>
#include 
int main()
{
boost::filesystem::path path("/usr/local/include"); 
bool result = boost::filesystem::is_directory(path);
return 0;
}</stdio.h>

推荐答案

您可能需要研究以下API方法:

You might want to look into this API method:

DWORD WNetAddConnection3(HWND hwndOwner,              // owner window
                         LPNETRESOURCE lpNetResource, // connection details
                         LPTSTR lpPassword,           // password string
                         LPTSTR lpUserName,           // user name string
                         DWORD dwFlags                // connection options);


文件和文件夹(本地或远程)之间的关系与操作系统有关,与应用程序无关.

如果您的帐户有权访问资源并且网络已正确配置,则可以访问路径为"\\ networkname \ resourcename \ folder \ file"的任何文件.

在Windows中,这是通过称为CIFS的协议实现的,而在Linux中,这是通过称为NFS的协议实现的.
Windows和Linux都有驱动程序,可以在其自身上实现其他协议.

如果这不起作用,请检查如何配置网络以及如何在另一台计算机上授权用户帐户.
避免在网络上实现自己的文件通信".我们已经有了所需的所有标准,甚至还有更多!
The relation between file and folders (either local or remote) is something pertinent to the operating system, not to applications.

If your account has the privilege to access a resource AND the network is properly configured, you can access whatever file with paths like "\\networkname\resourcename\folder\file".

In windows this is native by means of a protocol named CIFS, in Linux this is native by means to a protocol called NFS.
Both Windows and Linux have drivers to implement the other protocol over themselves.

If this doesn''t work, check how the network is configured and how user account are authorized on the other machine.
Avoid to implement yourself "file communications" across the network. We already have all the standard needed and even more!


这篇关于访问其他计算机上的共享文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆