如何在Windows Phone 8中从安装位置复制文件到隔离存储
How to Copy Files from Installed location to Isolated Storage in Windows Phone 8
我正在使用cocos2dx为WP8开发一个应用程序。我无法找到一个复制功能,可以帮助我将文件从安装位置复制到隔离存储。有人知道怎么做吗?请帮助
看一下来自Microsoft的"Marble Game"示例-它包含了许多说明性的代码片段。例如,这是加载数据的小编辑(异步):
concurrency::task<Platform::Array<byte>^> ReadDataAsync(
_In_ Windows::Storage::StorageFolder^ location,
_In_ Platform::String^ filename
)
{
return concurrency::task<Windows::Storage::StorageFile^>(location->GetFileAsync(filename)).then([=](Windows::Storage::StorageFile^ file)
{
return file->OpenReadAsync();
}).then([=](Windows::Storage::Streams::IRandomAccessStreamWithContentType^ stream)
{
uint32 fileSize = static_cast<uint32>(stream->Size);
auto reader = ref new Windows::Storage::Streams::DataReader(stream);
return concurrency::task<uint32>(reader->LoadAsync(fileSize)).then([=](uint32 count)
{
auto fileData = ref new Platform::Array<byte>(fileSize);
reader->ReadBytes(fileData);
return fileData;
});
});
}
如何使用(假设项目中包含了my_data.xml,并且"Content=True")
PCWSTR XML_FILE = L"my_data.xml"; // pay attention this is wide string
auto folder = Windows::ApplicationModel::Package::Current->InstalledLocation;
auto file = ref new Platform::String(XML_FILE);
concurrency::task<Platform::Array<byte>^> data_task = ReadDataAsync(folder, file);
concurrency::task_status res = data_task.wait();
Platform::Array<byte>^ data_buf = data_task.get();
现在您有了一个数据缓冲区,可以根据需要随意使用它或保存到隔离存储
相关文章:
- 将文件复制到自定义位置,存在字符串转换问题
- 将数据复制到磁盘上新位置的语法
- binding.gyp:如何使用"copies"部分在多个位置复制文件
- 如何修复"文件保留原始位置,复制后不复制扩展名"?
- 自复制文件到新位置tchar不兼容
- 向量如何在特定位置调用复制构造函数
- 将文件从资产复制到永久位置Qt + Android
- C 2D char阵列有时会在随机位置复制数据
- 将字符数复制到新字符串位置的字符串操作,例如 S[0]
- 将二进制文件复制到C++中的远程位置
- 在 C++ 中,从文件找到一行后从该位置复制到该文件的末尾
- 将图像文件(.BMP)复制到其他位置
- 如何将sql数据库文件从系统位置复制到另一个位置
- qt检查文件中是否存在文件,如果它没有提示用户输入其位置,则将文件复制到程序工作目录
- 从偏移位置开始复制内存
- 将文件从 SDCARD 位置复制到 Android 中 c 语言的另一个位置
- gcc 的 std::bind 在源中的哪个位置将参数复制到数据结构中?
- 将内存从char*复制到较大char*中的某个位置
- std::从向量的位置复制到向量的位置
- 如何使用指针将数组复制到内存中的其他位置