我们有这样的代码:
try
{
streamOptions = new IsolatedStorageFileStream( “FileName”,
FileMode.Open,
FileAccess.Read);
}
catch ( FileNotFoundException )
{
this.userSettings = new UserSettings();
load = false;
}这使得Visual在调试时经常闯入调试器,因此我希望使用“if”来保护上述代码,因此只有在存在IsolatedStorageFile时才能运行。但是,尚不清楚如何使用IsolatedStorageFile.FileExists()来检查IsolatedStorageFileStream即将打开的文件,例如,当我“新建”IsolatedStorageFile对象时,必须给出哪些选项。
发布于 2011-03-09 16:23:06
private bool IsolatedStorageFileExists(string name)
{
using (var folder = IsolatedStorageFile.GetUserStoreForDomain())
{
return folder.FileExists(name);
}
}发布于 2011-01-04 13:16:53
您可以在FileExists类上使用IsolatedStorageFile方法。
发布于 2014-03-27 14:18:46
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
if (store.FileExists(your_file_name)) { do something if file exist }
else { do something if file not exist}
}https://stackoverflow.com/questions/4593967
复制相似问题