[英]Can't use FileSystemWatcher in Visual Studio 2012
我是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?)
我在做什么错了(我确定是的)是一件非常简单的事情)。
要在创建,修改或删除文件或文件夹时得到通知,可以使用Windows.Storage.Search.StorageFolderQueryResult
和Windows.Storage.Search.StorageFileQueryResult
类以及ContentsChanged
事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.