通过Internet访问共享文件夹

时间:2016-04-10 04:57:48

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

我使用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);

enter image description here

1 个答案:

答案 0 :(得分:0)

您需要创建一个VPN才能使用互联网访问您的个人网络,另一种选择是使用谷歌驱动器或微软skydrive等云存储。

相关问题