2014-04-10 118 views
0

我有一个FileManagement(FM)站点和多个IIS。在每个IIS上,我存储了一些文件,所有这些文件都在共享文件夹下。我需要为客户端创建一个API,当客户端通过服务器地址,物理路径时,FM将从指定的IIS下载文件并返回给客户端。使用Asp.Net Web API从共享文件夹下载文件

这是一个路径文件Menu.txt穿上IIS答:

的App_Data \店\ Menu.txt。 App_Data与名称共享文件夹:\ SERVER-AppData。

当我通过参数设置为API,这将是这样的:

服务器地址:IISA IP地址

路径:\ SERVER-应用程序数据\店\ Menu.txt

我用在Test API项目中下载WebClient。

// Create a new WebClient instance 
WebClient myWebClient = new WebClient(); 
myWebClient.Credentials = new System.Net.NetworkCredential("username", "password", "domain"); 

// Concatenate the domain with the Web resource filename. 
string myStringWebResource = Path.Combine(serverAddress, path); 
string store = @"E:\file.txt"; 

// Download the Web resource and save it into the current filesystem folder. 
byte[] bytes = myWebClient.DownloadData(myStringWebResource); 

当我运行它时,它说:用户名或密码错误。但在网络中的窗口资源管理器。我使用用户名和密码连接到该服务器是正确的。

回答

-1

将文件存储在数据库中而不是物理文件中。

然后,您可以从任何附加的IIS计算机下载。

+0

我无法将文件存储在数据库中,每个IIS上存储的文件 – TPL