- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在开发 Windows Phone 7 应用程序,我想知道是否有人对我是否必须在创建目录之前检查目录是否存在以及这样做的优点/缺点有什么明确的答案这样做是。据我所知,通过逐步执行我的代码,以下两个代码块以相同的方式工作:
using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
//ensure directory exists
String sDirectory = System.IO.Path.GetDirectoryName(sPath);
if (!appStorage.DirectoryExists(sDirectory))
{
appStorage.CreateDirectory(sDirectory);
}
}
和
using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
//ensure directory exists
String sDirectory = System.IO.Path.GetDirectoryName(sPath);
appStorage.CreateDirectory(sDirectory);
}
使用第二段代码安全吗?如果目录已经存在,它似乎不会抛出异常,而且似乎也只保留目录的内容。
最佳答案
IsolatedStorageFile.CreateDirectory
将在内部调用 Directory.CreateDirectory
。 documentation Directory.CreateDirectory
状态:
If the directory already exists, this method does nothing.
换句话说,您不需要检查该目录是否存在。该方法已经为您做到了。
关于c# - 使用 IsolatedStorage,是否需要在创建目录之前检查目录是否存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3751372/
如何获取 WPF 应用程序的隔离存储文件的完全限定路径? 最佳答案 您可以使用反射来做到这一点,如 linked 所示。论坛帖子: IsolatedStorageFileStream oStream
Application1 使用 Microsoft Enterprise Library Caching Application Block 和 IsolatedStorageBackingStore
我有一个包含一些预定义名称的 xml 文件。我希望它在我执行应用程序时位于 IsolatedStorage 中。 我知道如何创建数据并将数据保存到 IsolatedStorage 但如何以可视方式复制
在我的 Windows Phone 7 应用程序中,我有一些设置保存在 IsolatedStorage 中。这些设置可以在我的应用程序中更改。我的问题是这些设置并不总是被保存。如果我使用主页按钮退出应
我在 Silverlight 应用程序中使用 IsolatedStorage 进行缓存,因此我需要知道该文件是否存在,我使用以下方法执行此操作。 我找不到 IsolatedStorage 的 File
我需要获取给定 IsolatedStorage 文件夹中所有文件的列表。 IsolatedStorage 的根目录之外有子文件夹,这些需要包含在列表中。 通常的 System.IO 类不能与 Isol
简单的问题,之前有人问过,但没有人给我正确的答案,所以我会非常具体。 我需要在 Windows Phone 中读取 IsolatedStorage 的两个设置。设置为 ExitAlert 和 Orie
我遇到一个问题,每次我第一次运行应用程序时都会收到 IsolatedStorageException(“IsolatedFileStorageStream 上不允许的操作”)。随后运行该应用程序时,它
我想将存储在 IsolatedStorage 中的图像设置为图 block 的背景图像。 我们以这种方式创建图 block : StandardTileData tile = new Standard
有没有办法改变 IsolatedStorage 文件的位置?我正在使用 .NET 3.5sp1 并使用 C# 编写我的应用程序 我想将其位置更改为 D:\TempDir。 最佳答案 我不相信它不是。我
Winform 应用程序在我们的 Intranet 中与 ClickOnce 一起发布。我们将个人对 GUI 的偏好存储在隔离存储中。一切正常:) 问题是当我们有一个新版本的应用程序时,我们发布...
我正在开发 Windows Phone 7 应用程序,我想知道是否有人对我是否必须在创建目录之前检查目录是否存在以及这样做的优点/缺点有什么明确的答案这样做是。据我所知,通过逐步执行我的代码,以下两个
我需要重命名 IsolatedStorage 中的文件。我该怎么做? 最佳答案 在 native C# 中似乎没有这样做(在 native Win32 中可能有,但我不知道)。 您可以做的是打开现有文
我需要为我的 Windows Phone 应用程序创建隔离存储,这是一个显示您所有业务文档的业务应用程序,您可以从那里拒绝和接受业务文档,现在我的问题是我不知道在哪里从隔离存储开始?我已经通过谷歌,但
由于对 silverlight 使用 isolatedstorage 存储可以提供一种在本地存储用户数据并且无需连接到 internet 的方法,我很想听听您对智能同步 dbdata 和 silver
我正在尝试使用 C# 类 IsolatedStorageFile 将一些数据写入我的应用程序中的文件。这是使用模拟器。我想在我的电脑上查看它是否有效(即,查看记事本中的文件)。我在哪里可以找到该文件?
我是 silverlight 的新手,我的应用程序有一些问题。我将应用程序日期保存在数据库和 IsolatedStorage 中。 我在 UI 的顶部有一个图像控件,用户可以在其中始终看到应用程序的当
我在一个解决方案中有两个 Windows 窗体应用程序和库。 库类可以在 IsolatedStorage 中创建新的文件夹和文件,并列出 IsolatedStorage 中的所有文件和文件夹。 第一个
我正在编写一个 WP8(XAML 和 C#)应用程序来从 SkyDrive 读取一个文本文件并将其保存到 IsolatedStorage 中。 好像是读取了文件,但是我得到的数据是文件的描述,而不是文
大家好,我在尝试编辑我的 UI 时遇到了一个孤立的异常 它说 Unable to determine application identity of the caller. at System.IO.
我是一名优秀的程序员,十分优秀!