首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >IsolatedStorageFile.DeleteFile不起作用

IsolatedStorageFile.DeleteFile不起作用
EN

Stack Overflow用户
提问于 2014-06-18 14:06:19
回答 1查看 704关注 0票数 0

我试着做这样的事:

代码语言:javascript
复制
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    if (store.FileExists(fileName))
                    {
                        store.DeleteFile(fileName);
                    }
                }

但是System.IO.IsolatedStorage.IsolatedStorageException:无法删除文件。

怎么啦?

EN

回答 1

Stack Overflow用户

发布于 2014-06-20 07:33:03

所以我通过在打开文件时使用FileMode.Truncate来解决我的问题。

代码语言:javascript
复制
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    using (var fileStream = store.OpenFile(fileName, FileMode.Truncate, FileAccess.ReadWrite, FileShare.ReadWrite))
                    {
                        //Do stuff
                    }
                }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24287748

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档