[英]C# PrivateFontCollection AddFontFile from relative path
我在root文件夾中有OpenSans-Light.ttf:〜/ fonts / open-sans / OpenSans-Light.ttf
PrivateFontCollection privateFontCollection = new PrivateFontCollection();
privateFontCollection.AddFontFile("~/fonts/open-sans/OpenSans-Light.ttf");
但我得到“System.IO.FileNotFoundException:找不到文件”
如何定位該字體文件?
我找到了一個使用MapPath的解決方案:
PrivateFontCollection privateFontCollection = new PrivateFontCollection();
privateFontCollection.AddFontFile(HttpContext.Current.Server.MapPath("~/fonts/open-sans/OpenSans-Light.ttf"));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.