我现在有张图片(名称为buf),放在工程文件夹根目录里面。现在我在菜单栏添加了保存图片选项。

------解决思路----------------------
在选入保存的路径之前,添加了open_s,好像有点问题。还是不能get the data
----------------------------------------------------------------------------------------------------------
我也是醉了,你都不调试的么?
你这逻辑怎么越来越乱了,路径选择之前,也就说路径都还没有,你咋么open_s撒?
//buf data
//....
//....
//chose a file path with ‘save file dlg’
CFileDialog dlg(FALSE); ///TRUE is ‘OPEN’ dlg,FALSE is ‘SAVE AS’ dlg
if(dlg.DoModal()==IDOK)
{
FilePathName=dlg.GetPathName();
//Open file first , then Write file data , and Close file last;
fopen_s(&f,FilePathName.GetBuffer(),"wb");
if(f)
{
fwrite(buf,strlen(buf),1,f);
fclose(f);
}
FilePathName.ReleaseBuffer();
}