在我的方法中,我试图将图像保存在项目目录中的文件夹中。我试过只是放置文件夹的直接文件路径,但是当项目运行时会给我一个错误。将图像保存到asp.net/c#中的项目文件夹中
在c#中有一种内置的扩展,它允许我将这个图像保存在我的目录中的一个文件夹中;或者只是简单地访问我的目录而不钻取我的项目保存在我的计算机上的位置?
private void CreateBarcode()
{
var bitmapImage = new Bitmap(500,300);
var g = Graphics.FromImage(bitmapImage);
g.Clear(Color.White);
UPCbarcode barcode = new UPCbarcode(UPCbarcode.RandomGeneratedNumber(), bitmapImage, g);
string [email protected]"images/image1.jpg";
bitmapImage.Save(filepath,System.Drawing.Imaging.ImageFormat.Jpeg);
}
你会得到什么错误? – Divi
重复? [将文件保存在我的项目中的指定文件夹](http://stackoverflow.com/questions/14788217/saving-a-file-in-a-specified-folder-inside-my-project) –
Try Server.MapPath ( “图像/” +文件名) –