0
我想在Windows Phone上使用C++創建一個文件,但是我不熟悉Win32 API,你可以給一些代碼片段如何使用它們嗎?順便說一句,在這裏我也想知道,用C++創建本地文件的速度是否比windows phone平臺上的c#更快?謝謝!如何在Windows Phone 8上使用C++創建文件?
我想在Windows Phone上使用C++創建一個文件,但是我不熟悉Win32 API,你可以給一些代碼片段如何使用它們嗎?順便說一句,在這裏我也想知道,用C++創建本地文件的速度是否比windows phone平臺上的c#更快?謝謝!如何在Windows Phone 8上使用C++創建文件?
C++的主要挑戰是找到可寫入的根目錄。
您不需要使用C++中的Win32協議(也可能是最不便攜的選項)。您還可以使用標準C FILE * API,標準C++流API或新的WinRT異步文件API。
例如使用FILE *(來自https://stackoverflow.com/a/15988970/694641)。
void SaveToFile()
{
// get local folder (= isolated storage)
auto local = Windows::Storage::ApplicationData::Current->LocalFolder;
auto localFileNamePlatformString = local->Path + "\\game.sav";
FILE* pFile;
auto f = _wfopen_s(&pFile, localFileNamePlatformString->Data(), L"w");
auto res1 = fprintf(pFile, "123456789");
auto res2 = fclose(pFile);
}
我不會擔心文件的速度,除非您嘗試修復已知的性能問題。