}
[STAThread] static void Main() { Application.Run(new frmMain()); }
private void btnUpload_Click(object sender, System.EventArgs e) { try { //用文件的路径信息创建一个文件对象 FileInfo MyPicture=new FileInfo(this.txtFilePath.Text); //检查文件的存在性 if(!MyPicture.Exists) { MessageBox.Show("文件不存在!"); } else { //检查文件的扩展名,如果不符合要求就返回 switch(MyPicture.Extension.ToUpper()) { case ".JPG":this.UpLoadImageFile(MyPicture);break; case ".GIF":this.UpLoadImageFile(MyPicture);break; case ".BMP":this.UpLoadImageFile(MyPicture);break; default:MessageBox.Show("文件类型不正确!");break; } } } catch { MessageBox.Show("文件路径信息不正确!"); } }
/// <summary> /// 向数据库写入图像文件 /// </summary> private void UpLoadImageFile(FileInfo obj) { try { //创建一字节数组,用来存储图像文件.(数组的长度是图像文件的长度)
上一页 [1] [2] [3] 下一页
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18