iT邦幫忙

0

C# WEB FORM 於.CS 檔案,要如何抓相關路徑?

  • 分享至 

  • xImage

參考
https://dotblogs.com.tw/atowngit/2009/08/23/10198
我使用
string filePath = System.Web.HttpContext.Current.Server.MapPath("~");

但結果,卻是NULL

水無痕 iT邦新手 3 級 ‧ 2021-08-11 19:44:31 檢舉
你列的語法,我跑是正常的 !
都是這樣用沒錯啊,除非你不是在WebForm執行
noway iT邦研究生 3 級 ‧ 2021-08-12 11:28:49 檢舉
您好: 我是在 「.CS」 內執行,這樣OK嗎?
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

1
PPTaiwan
iT邦好手 1 級 ‧ 2021-08-12 13:10:30

試試看這方法

System.AppDomain.CurrentDomain.BaseDirectory

這是直接針對你現在應用程式目錄,web、WinForm 一體適用

我要發表回答

立即登入回答