C#用SaveFileDialog保存图片,到保存的路径看对应的名字的bmp文件,大小为0k代码如下:
SaveFileDialog savePicture = new SaveFileDialog();//声明一个savefiledialog的对象用于保存
            savePicture.FileName = "Picturebox1";
            savePicture.Title = "保存图片";
            savePicture.Filter = "图片类型(*.jpg,*.gif,*.bmp)|*.jpg,*.gif,*.bmp";
            savePicture.RestoreDirectory = true;//保存对话框记忆上次打开的目录            string localFilePath, fileNameExt, newFileName, FilePath;            //  savePicture.ShowDialog();
            if (savePicture.ShowDialog() == DialogResult.OK)
            {
                //获得文件路径
                localFilePath = savePicture.FileName.ToString();                if (savePicture.FileName != "")
                {
                    string temp = savePicture.FileName;
                    pictureBox1.Image.Save(temp);
                }                //获取文件名,不带路径
                fileNameExt = localFilePath.Substring(localFilePath.LastIndexOf("\\") + 1);                //获取文件路径,不带文件名
                FilePath = localFilePath.Substring(0, localFilePath.LastIndexOf("\\"));                //给文件名前加上时间
                newFileName = DateTime.Now.ToString("yyyyMMdd") + fileNameExt;                //在文件名里加字符
                savePicture.FileName.Insert(1, "dameng");                System.IO.FileStream fs = (System.IO.FileStream)savePicture.OpenFile();//输出文件\

解决方案 »

  1.   

    这一句有问题
    System.IO.FileStream fs = (System.IO.FileStream)savePicture.OpenFile();//输出文件\SaveFileDialog.OpenFile():
    For security purposes, this method creates a new file with the selected name and opens it with read/write permissions. This can cause unintentional loss of data if you select an existing file to save to. To save data to an existing file while retaining existing data, use the File class to open the file using the file name returned in the FileName property.可以看出OpenFile()会创建新文件,而不是仅仅打开。
      

  2.   

    你把文件名整理好了,再用 pictureBox1.Image.Save(temp); 啊
      

  3.   

    OpenFile()会创建新文件;看看这个,C++的,跟C#差不多的http://blog.csdn.net/buyueliuying/archive/2011/02/08/6174667.aspx