我想寫入文件系統中的目錄C:\目錄名,目前我有這樣的代碼:寫目錄中的文件系統
if (! System.IO.File.Exists (HttpContext.Current.Server.MapPath (filename)))
{
TXTFile = new System.IO.StreamWriter (HttpContext.Current.Server.MapPath (filename));
}
else
{
TXTFile = System.IO.File.AppendText (HttpContext.Current.Server.MapPath (filename));
}
但這種方式在寫應用程序文件夾。 如何解決它?
如果你已經有一個c:\像路徑,你不需要使用mappath。當你有一個服務器路徑時需要使用Mappath,並且需要使用ac:\ like path ... –
另外,由於這看起來是一個ASP.NET應用程序,因此您可能無法訪問您嘗試寫入的路徑。 –