1. 程式人生 > >判斷檔案是否存在某路徑下

判斷檔案是否存在某路徑下

if (System.IO.File.Exists(Server.MapPath("/images/qrcode/vpopc_qrcode/GZ/") + zhbh + ".jpg"))
{
gzewm.Attributes.Add("src", "/images/qrcode/vpopc_qrcode/GZ/" + zhbh + ".jpg");
}
else
{
//生成二維碼
string Img = "";
Bitmap bt;
string success = "true";
string enCodeString = "http://w.vpooo.com/html/gz/GZ_GZZC.htm?zhbh=" + zhbh + "&type=NGQsNDEsNDksNGU_";
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();
//二維碼編碼方式
qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
//每個小方格的寬度
qrCodeEncoder.QRCodeScale = 10;
//二維碼版本號 DateTime.Now.ToString("yyyymmddhhmmss");
qrCodeEncoder.QRCodeVersion = 0;
bt = qrCodeEncoder.Encode(enCodeString, Encoding.UTF8);
string filename =zhbh;
string path = Server.MapPath("/images/qrcode/vpopc_qrcode/GZ/") + filename + ".jpg";
bt.Save(path);
gzewm.Attributes.Add("src", "/images/qrcode/vpopc_qrcode/GZ/" + filename + ".jpg");
}