【问题标题】:Access Shared Folder over internet通过 Internet 访问共享文件夹
【发布时间】:2016-07-31 06:34:00
【问题描述】:

我使用 C# 创建网站,我在另一台网络计算机上有共享文件夹, 现在我需要使用(域或静态 IP - 用户名 - 密码)从我的网页浏览共享文件夹中的所有文件和文件夹。 我需要用户可以访问共享文件夹文件并仅下载它。

此代码可以从网络复制文件,但不能通过互联网复制:

NetworkCredential theNetworkCredential = new NetworkCredential(@"Domain\Username", "Password");
        CredentialCache theNetCache = new CredentialCache();
        theNetCache.Add(new Uri(@"\\Domain"), "SHARED", theNetworkCredential);
        string[] theFolders = Directory.GetDirectories(@"\\Servername\SHARED\");




        string sourceDirectory = theFolders[1];
        string targetDirectory = @"E:\Shared";

        DirectoryInfo diSource = new DirectoryInfo(sourceDirectory);
        DirectoryInfo diTarget = new DirectoryInfo(targetDirectory);

        CopyAll(diSource, diTarget);

【问题讨论】:

    标签: c# network-programming network-share network-connection


    【解决方案1】:

    您需要创建一个 VPN 才能使用互联网访问您的个人网络,另一种选择是使用云存储,如 google drive 或 microsoft skydrive。

    【讨论】:

    • 感谢您的回复。我的共享文件夹每天更新(新文件或删除文件)。所以我需要访问这个文件夹。
    猜你喜欢
    • 2011-03-06
    • 2020-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-15
    • 1970-01-01
    • 2022-07-31
    • 1970-01-01
    相关资源
    最近更新 更多