WebService项目中的Web.config配置代码
<appSettings>
<add key="UploadFileFolder" value="/Uploads/TestUpload/" />
</appSettings>
WebService项目中的ImageService.asmx代码
/// <summary>
/// Webservice中的下载文件处理函数
/// </summary>
/// <param name="filePath">文件路径</param>
/// <returns>返回文件流</returns>
[WebMethod(Description = "下载服务器站点文件,传递文件相对路径")]
public byte[] DownloadFile(string strFilePath)
{
FileStream fs = null;
string CurrentUploadFolderPath = Server.MapPath(ConfigurationManager.AppSettings["UploadFileFolder"]);
string CurrentUploadFilePath = CurrentUploadFolderPath + strFilePath;
if (File.Exists(CurrentUploadFilePath))
{
try
{
///打开现有文件以进行读取。
fs = File.OpenRead(CurrentUploadFilePath);
int b1;
System.IO.MemoryStream tempStream = new System.IO.MemoryStream();
while ((b1 = fs.ReadByte()) != -1)