我認爲你可以在此使用下載服務器端實現,可以爲你訪問這些文件,然後通過http服務它們。
一個HttpHandler,其ProcessRequest方法可以(非常semplified)是這樣的:
public void ProcessRequest(HttpContext context)
{
if (context.Request.Params["file"] != null)
{
string filename = context.Request.Params["file"].ToString();
context.Response.Clear();
context.Response.ClearContent();
context.Response.ClearHeaders();
context.Response.Buffer = true;
FileInfo fileInfo = new FileInfo(filename);
if (fileInfo.Exists)
{
context.Response.ContentType = /* your mime type */;
context.Response.AppendHeader("content-disposition", string.Format("attachment;filename={0}", fileInfo.Name));
context.Response.WriteFile(filename);
}
context.Response.End();
}
}
,那麼你將建立鏈接指向你與文件PARAM處理程序:
var exDir = @"\\Server\folder\Exception";
DirectoryInfo dir = new DirectoryInfo(exDir);
foreach (FileInfo exFile in dir.GetFiles())
{
exLabel.Text += @"<a href='downloader.ashx?file="+ exFile.Name + "'> "+exFile.FullName+" </a><br/>";
}
請記住在web.config中設置處理程序:
<system.web>
<httpHandlers>
...
<add verb="*" path="downloader.ashx" type="YourNamespace.downloader"/>
</httpHandlers>
</system.web>
(當然這個示例很簡單樂和我認爲充滿錯誤,但只是爲了澄清的方式)
http://kb.mozillazine.org/Links_to_local_pages_don%27t_work問題是由於Firefox和不是代碼 – bananajunk