简体   繁体   English

网络文件复制

[英]File.copy over network

I'm trying to copy files from a local pc to a server with file.copy. 我正在尝试使用file.copy将文件从本地PC复制​​到服务器。 but whitou succes. 但惠头成功。 there are no error but it doesn't show up on the server. 没有错误,但未在服务器上显示。 my Permissons are alright thow. 我的许可证很好。

here is what i do. 这是我的工作。

    public static void UploadFiles(string path, string[] files, 
                         string[] uploadPlace, ObserverDelegate observerDelegete)
    {
        try
        {
            Directory.CreateDirectory(path);

            for (int i = 0; i < files.Count(); i++)
            {
                observerDelegete(files[i]);
                File.Copy(files[i], uploadPlace[i]);
            }
        }
        catch (UnauthorizedAccessException uoe) { }
        catch (FileNotFoundException fnfe) { }
        catch (Exception e) { }        
    }

There is no error because you're catching and swallowing all of the possible exceptions... 没有错误,因为您正在捕获并吞没所有可能的异常...

    catch (UnauthorizedAccessException uoe) { }
    catch (FileNotFoundException fnfe) { }
    catch (Exception e) { }  

which effectively masks the errors from you as a programmer. 有效地掩盖了您作为程序员的错误。 Take those statements out, recompile the code, and see what exceptions get thrown. 删除这些语句,重新编译代码,并查看抛出了哪些异常。

It's likely a permissions or network connectivity issue. 可能是权限或网络连接问题。 Windows is nice enough to let you know for sure. Windows足以让您确定。

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

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