我創建了一個Web應用程序來打開本地目錄中的文件(無論是記事本,Excel,PDF等)。在IIS Express中運行文件時打開文件,但在IIS本地Web服務器中,它不打開文件。MVC應用程序在IIS Express中工作正常,但在本地IIS網絡服務器中不工作
我有Visual Studio中項目中的文件。
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(@"D:// Path ");
IEnumerable<System.IO.FileInfo> fileList = dir.GetFiles("*.*");
var newestFile =
(from file in fileList
//where file.Contains(para)
orderby file.CreationTime
where file.FullName.Contains(para)
select new { file.FullName, file.CreationTime })
.Last();
Process.Start(newestFile.FullName);
return "";
Process.Start在服務器上運行,而不是在客戶端上運行。你是否期望用戶看到這些文件打開? – Crowcoder
是的。用戶需要在process.Start() –
中打開指定的文件。這不起作用,他們必須下載文件。 – Crowcoder