2016-04-10 78 views
1

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

回答

0

你需要創建一個VPN使用互聯網有自己的網絡接入,其他替代方案是使用雲存儲,如谷歌驅動器或微軟的skydrive。

+0

感謝您的回覆。我的共享文件夾每天更新(新文件或刪除文件)。所以我需要訪問這個文件夾。 –