C# 为什么我能';你不能加载这个图像吗?
我想用C语言检索jpg图像,真是疯了# 这是我的班级:C# 为什么我能';你不能加载这个图像吗?,c#,image,system.drawing,C#,Image,System.drawing,我想用C语言检索jpg图像,真是疯了# 这是我的班级: namespace PdfReport { // Classe base che rappresenta un PDF: public class iTextDocumentBase : MyManagerCSharp.ManagerDB { // Oggetto MemoryStream che contiene il PDF: protected System.IO.MemoryS
namespace PdfReport
{
// Classe base che rappresenta un PDF:
public class iTextDocumentBase : MyManagerCSharp.ManagerDB
{
// Oggetto MemoryStream che contiene il PDF:
protected System.IO.MemoryStream _risultatoMemoryStream = new System.IO.MemoryStream();
protected iTextSharp.text.Document _document; // Generico documento di iText valido per qualsiasi formato di output
protected iTextSharp.text.Chapter _capitolo; // Contenitore per un insieme di Section opportunamente sequenziate
protected iTextSharp.text.Section _section; // Parte del Document costituita da un insieme di Paragraph opportunamente disposti
protected System.Drawing.Image _backgroundImg = System.Drawing.Image.(Server.MapPath("~/Path/Relative/To/Root.jpg"));
..........................................................
..........................................................
..........................................................
}
如你所见,我正试图通过这一行获得图像:
protected System.Drawing.Image _backgroundImg = System.Drawing.Image.(Server.MapPath("~/Path/Relative/To/Root.jpg"));
问题是我获得了以下错误消息:
为什么??我能做些什么来解决呢?这个问题似乎与图像无关。首先,这是无效的C#语法: 你不能只把一个
(
放在
之后。你需要在那里给出一个方法名(在这种情况下,可能是从文件中)
至于“名称“服务器”在当前上下文中不存在”错误,发生这种情况是因为您缺少程序集引用或使用Server
类的语句。Server.MapPath()
是用于ASP.NET项目的方法。您正在处理ASP.NET项目吗
Error 78 The name 'Server' does not exist in the current context C:\Develop\EarlyWarning\public\Implementazione\Ver2\PdfReport\iTextDocumentBase.cs 43 79 PdfReport
Error 77 Identifier expected C:\Develop\EarlyWarning\public\Implementazione\Ver2\PdfReport\iTextDocumentBase.cs 43 78 PdfReport
System.Drawing.Image.(Server.MapPath("~/Path/Relative/To/Root.jpg"));