不能在Visual Studio 2012中使用FileSystemWatcher
本文关键字:FileSystemWatcher 2012 Visual Studio 不能 | 更新日期: 2023-09-27 17:49:59
我是Visual Studio和c#的新手。我习惯使用XCode和Objective-C,但我现在试图写一个Windows 8应用程序。我试图设置一个FileSystemWatcher
,当用户点击一个按钮在我的应用程序,但由于某种原因,Visual Studio拒绝承认,我可以做到这一点,并抛出一个错误。以下是我写的一个例子:
using System;
using System.IO;
...
namespace My_APP
{
...
public sealed partial class MainPage : My_App.Common.LayoutAwarePage
{
...
public void button_click_1(object sender, RoutedEventArgs e)
{
FileSystemWatcher watch = new FileSystemWatcher();
}
}
}
FileSystemWatcher
用红色下划线两次,错误:Error 1 The type or namespace name 'FileSystemWatcher' could not be found (are you missing a using directive or an assembly reference?)
我做错了什么(我确信这是非常简单的)
因为FileSystemWatcher
不包含在用于Windows 8应用程序的。net版本中。如果它得到支持,你会看到。. NET用于Windows Store应用程序,在:Windows 8中支持",见MSDN页面的版本信息部分。将此与可用的BinaryReader
进行对比。
窗口。存储空间具有Windows 8应用程序中文件系统访问的api
要在文件或文件夹被创建、修改或删除时获得通知,您可以使用Windows.Storage.Search.StorageFolderQueryResult
和Windows.Storage.Search.StorageFileQueryResult
类以及ContentsChanged
事件。
- http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.search.storagefilequeryresult.aspx
- http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.search.storagefolderqueryresult.aspx