最近在开发一个企业管理软件,在查相关资料时找到了“51CTO技术博客”,所以开了这个博客,希望能和大家交流交流!个人能力有限,请大家多多指教,呵呵!
         今天我主要是说一下c#中如何删除指定的图片:
         
           //方法一:直接删除指定图片
            System.IO.FileInfo file = new System.IO.FileInfo(Application.StartupPath + " \\1.jpg");
            if (file.Exists)
            {
                file.Delete();
            }
 
            //方法二:采用函数可以多处使用
           public static bool FilePicDelete(string path)
            {
                bool ret = false;
                System.IO.FileInfo
                file = new System.IO.FileInfo(path);
                if (file.Exists)
                    //文件是否存在,存在则执行删除
                {
                    file.Delete();
                    ret = true;
                }
                return ret;
            }
           删除按钮点击事件
            rivate void btdel_Click(object sender, EventArgs e)
          {

                    if (FilePicDelete(Application.StartupPath + " \\1.jpg"))
                   {
                            MessageBox.Show("该图片已经成功删除!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                             MessageBox.Show("删除失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     }
            }
 
            开发点滴交流,技术有限,请大家见笑了 ^_^  !