public ActionResult PreviewerForHtmlPack(FormCollection form) { VmPreviewerForHtmlPack ViewModel = new VmPreviewerForHtmlPack(); ConvertService ConvertServ = new ConvertService(); //掃描目標資料夾並取出列表放在下拉式選單中 string SelectedItem = (!string.IsNullOrEmpty(form["select-file-or-directory"])) ? Path.GetFileName(form["select-file-or-directory"]) : string.Empty; ViewModel.FileSelectList = ConvertServ.GetSelectList(GlobalVars.LOADING_FILES_HTMLPACK, "*", SearchOption.TopDirectoryOnly, true); //取得索引並轉換目標檔案 if (Request.RequestType == "POST" && !string.IsNullOrEmpty(SelectedItem)) { ViewModel.FileSelectList.Find(x => x.Text == SelectedItem).Selected = true; string ConvertPath = ViewModel.FileSelectList.Single(x => x.Text == SelectedItem).Value; ViewModel.CssContent = ConvertServ.GetNewHtmlPackCssContent(ConvertPath); ViewModel.SheetList = ConvertServ.GetObjectFromHtmlPack(ConvertPath); } return(View(ViewModel)); }