該程式片段主要是<判斷檔案路徑是否有檔案,有就window.open,如沒有則轉到錯誤頁面處理>。
string url = "\\\\report\\\\exp_year_report_" + strYear + ".html"; string path = Server.MapPath("~") + url; } |
以上程式有幾個技術重點分析:
1、System.IO.File.Exists(path);//使用絕對路徑:檔案存在的判斷語法,一定要引用<using System.Text>。
2、ScriptManager.RegisterStartupScript(Page, GetType(), "ALERT", "window.open('" + url + "','_middle','menubar=no,status=no,scrollbars=yes,toolbar=no');", true):
Script語法,開啟window open,這裡url為資料夾之相對路徑。
3、string path = Server.MapPath("~") + url:絕對路徑的語法。