如何使用c++将二进制数据写入windows store应用程序中的文件
How to write Binary data to a file in a windows store app using c++
嘿,我在文件IO上遇到了麻烦。我正在使用一些标准的文件指针的东西,但我一直得到这个错误:在0x58CBC465 (msvcr120_app.dll)在ChemicalWar.exe未处理的异常:一个无效的参数被传递给一个函数,认为无效的参数致命。
现在从我收集到的,我认为这与没有权限写入默认位置有关,但我不确定如何更改位置。
这是目前为止我写的给我带来麻烦的代码:
FILE* ofile;
NametoBinary(_filename);
fopen_s(&ofile, (char*)folder->ToString(), "wb");
fwrite(&animhead, sizeof(Afhead), 1, ofile);
fwrite(binbuff.data(), sizeof(unsigned char), binbuff.size(), ofile);
fclose(ofile);
在第一次fwrite调用时中断。任何帮助都太好了。
所以我想出了解决方案,所以我将把它贴出来,以防其他人需要知道。
FILE* ofile = nullptr;
NametoBinary(_filename);
auto folder = Windows::Storage::ApplicationData::Current->RoamingFolder;
std::wstring ws(folder->Path->Data());
std::string full(ws.begin(), ws.end());
full += "\";
full += _filename;
fopen_s(&ofile, full.c_str(), "wb");
if (nullptr == ofile) return false;
fwrite(&animhead, sizeof(Afhead), 1, ofile);
所以新的windows应用程序有自己的FileI0系统。此解决方案将文件保存在appdata文件夹中的一个文件夹中。
相关文章:
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 在Linux for Windows上编译C++代码时出错
- 在Windows上用C++裁剪HBITMAP
- C++ Windows 驱动程序MSB3030无法复制该文件,因为它找不到
- 如何加载(或映射)文件部分的最大大小,但适合在Windows上的RAM
- std::threads可以从Windows DLL中的全局变量创建/销毁吗?
- 当我编译webrtc服务器时,Windows上只支持clang-cl
- 为什么在Windows上的VS 2019和Clang 9中"size_t"在没有标题的情况下工作
- Windows/Cygwin - 不能使用 pybind11 - 犯错误
- Windows 10-使用gtkmm-3.0库和g++[包括再现]的分段故障
- 在Windows中以.exe的形式运行c++
- 为什么包含windows.h会产生语法错误,从而阻止类的实例化?(C2146,C2065)
- 如何获得WinRT / Windows 10 Store代码的HRESULT错误代码的描述
- 在c++, Windows Store Metro应用程序中设置控件的颜色
- 如何使用c++将二进制数据写入windows store应用程序中的文件
- 合并声音文件音频和记录在寡妇8 Metro Windows Store应用程序
- 如何在visual studio 2012中使用c++为windows store应用程序创建加法程序
- VS2012 "Project is incompatible"从设置为 "Windows Store App Support" 到 true 的消息
- Windows 8 (Store App) in C -如何禁用gzip压缩
- Windows Store Bluetooth