删除文件似乎不起作用 [英] Deleting a file doesnt seem to work

查看:86
本文介绍了删除文件似乎不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 我正在尝试使用Windows :: Storage :: StorageFile :: DeleteAsync()方法删除文件。但它似乎没有用。错误代码返回0. 该文件永远不会被删除。难道我做错了什么?

 I am trying to delete a a file using Windows::Storage::StorageFile::DeleteAsync() method. But it doesnt seem to work. The errorcode returns 0.  The file never gets deleted. Am I doing something wrong?

自动statusOperation = tempFile-> DeleteAsync(StorageDeleteOption :: PermanentDelete);

    &NBSP ;          statusOperation->完成= REF新AsyncActionCompletedHandler([](IAsyncAction ^ asyncInfo)

            &NBSP ;   {

                    汽车错误码= asyncInfo->错误码;

               } );;
                statusOperation-> Start();

auto statusOperation = tempFile->DeleteAsync(StorageDeleteOption::PermanentDelete);
               statusOperation->Completed = ref new AsyncActionCompletedHandler([](IAsyncAction ^asyncInfo)
                {
                    auto errorcode = asyncInfo->ErrorCode;
                });
                statusOperation->Start();

推荐答案

请注意 IAsyncAction
界面中未定义启动
方法。因此,您的代码无法通过编译。

Please note that Start method is not defined in IAsyncAction interface. So your code cannot pass compilation.

请尝试以下代码段。

任务< void>(tempFile-> DeleteAsync (StorageDeleteOption :: PermanentDelete).then([this](){......});

请参考
文件访问样本
 了解更多详情。

Please refer to File access sample for more details.

在同时,请检查其他应用是否正在访问此文件。

In the meantime, please check if this file is being accessed by other apps.


这篇关于删除文件似乎不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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