visual c++ - Access Denied in CreateFile2 (Windows 10) -
i trying write file via c++ code. getting "error_access_denied". 1 please me identify missing in below code. have write file using c++ project requirement.
handle hfile; hfile = createfile2(text("e:\\mytextfile.txt"), generic_write , file_share_read | file_share_write | file_share_delete, create_new, null); if (invalid_handle_value == hfile) { string^ msg = "uncached error"; switch (getlasterror()) { case error_file_not_found: msg = "file not found "; break; case error_access_denied: msg = "access denied "; break; default: break; } messagedialog(msg, "error").showasync(); } else { platform::string^ data = txtreadwrite->text->tostring(); writefile(hfile,&data, (dword)sizeof(data), (dword)0, null); closehandle(hfile); }
windows store apps run in low-privilege sandbox called app container. cannot access arbitrary files on system.
see the documentation details.
Comments
Post a Comment