使用文件调试 WP8 原生代码 [英] Debugging WP8 Native Code using a file

查看:24
本文介绍了使用文件调试 WP8 原生代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发具有一些本机代码(运行时组件)的 WP8 应用程序.在运行时组件中,我需要检查 c 样式数组的内容.因为这个数组不小,我想我能做的最好的就是把这个数组写在一个文件里使用 fopen/fwrite/fclose;检查fopen和fwrite的返回值,可以看到成功了.但我找不到该文件(使用 Windows Phone 电源工具).

I'm developing a WP8 app that has some native code (runtime component). Inside the runtime component I need to check to content of a c style array. Because this array is not small, I thought the best I could do is write the array in a file using fopen/fwrite/fclose; Checking the returned value from fopen and fwrite, I can see that it succeeded. But I cannot find the file (using Windows Phone Power Tools).

那么文件写到哪里去了?是否有另一种方法可以将数组的内容从 Visual Studio 转储到文件(在计算机上)?

So where has the file been written? Is there another way to dump the content of the array to a file (on the computer) from visual studio ?

推荐答案

感谢 Justin,

这是我最终的做法:

auto folder = Windows::Storage::ApplicationData::Current->LocalFolder;
Concurrency::task<Windows::Storage::StorageFile^> createFileOp(
    folder->CreateFileAsync(L"Data.bin", Windows::Storage::CreationCollisionOption::ReplaceExisting));

createFileOp.then(
    [nData, pData](Windows::Storage::StorageFile^ file)
    {
        return file->OpenAsync(Windows::Storage::FileAccessMode::ReadWrite);
    })
    .then([nData, pData](Windows::Storage::Streams::IRandomAccessStream^ stream)
        {
            auto buffer = ref new Platform::Array<BYTE>(pData, nData);

            auto outputStream = stream->GetOutputStreamAt(0);
            auto dataWriter = ref new Windows::Storage::Streams::DataWriter(outputStream);                        
            dataWriter->WriteBytes(buffer);

            return dataWriter->StoreAsync();
        })
   .wait();

现在将其与我的意思"进行比较:

Now compare that to what I "meant" :

FILE *fp = fopen("Data.bin", "wb");
if (fp)
{
    int ret = fwrite(pData, 1, nData, fp);
    fclose(fp);
}

这篇关于使用文件调试 WP8 原生代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆