要将文件夹形式的客户端位置复制到我的服务器 [英] Want to copy folder form client location to my server

查看:112
本文介绍了要将文件夹形式的客户端位置复制到我的服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private static bool CopyDirectory(string SourcePath, string DestinationPath, bool overwriteexisting)
        {
            bool ret = false;
            try
            {
                SourcePath = SourcePath.EndsWith(@"\") ? SourcePath : SourcePath + @"\";
                DestinationPath = DestinationPath.EndsWith(@"\") ? DestinationPath : DestinationPath + @"\";

                if (Directory.Exists(SourcePath))
                {
                    if (Directory.Exists(DestinationPath) == false)
                        Directory.CreateDirectory(DestinationPath);

                    foreach (string fls in Directory.GetFiles(SourcePath))
                    {
                        FileInfo flinfo = new FileInfo(fls);
                        flinfo.CopyTo(DestinationPath + flinfo.Name, overwriteexisting);
                    }
                    foreach (string drs in Directory.GetDirectories(SourcePath))
                    {
                        DirectoryInfo drinfo = new DirectoryInfo(drs);
                        if (CopyDirectory(drs, DestinationPath + drinfo.Name, overwriteexisting) == false)
                            ret = false;
                    }
                }
                ret = true;
            }
            catch (Exception ex)
            {
                ret = false;
            }
            return ret;
        }


实际上我想将文件夹从客户端系统复制到我的服务器.我对上面的代码从其复制文件夹????????
感到困惑 在我的本地系统中,它可以工作,但是可以在客户端计算机上工作..

请帮忙.


Actually I want to copy folder from client system to my Server.I am quit confuse with above code from where its copying folder ????????
In my local system its working but will it work on client machine..

please help.

推荐答案

上面的CopyDirectory使用递归,看起来像是可以使用.

只要您具有正确的权限,它就可以在网络上工作.

换句话说,如果您有权使用资源管理器从源中读取并手动写入目标,则可能可以使它正常工作.
CopyDirectory above uses recursion and looks like it would work.

It should work across a network as long as you have the correct permissions.

In other words if you have permissions to read from the source and write to the destination manually using explorer you can probably get this to work.


如果在客户端计算机上没有权限,它将可以工作问题.
it will work if on client machine there is no permission issue.


这篇关于要将文件夹形式的客户端位置复制到我的服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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