繁体   English   中英

无法在Visual Studio 2012中使用FileSystemWatcher

[英]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 8应用程序使用的.NET版本不包括FileSystemWatcher 如果支持,则将在MSDN页面的 “版本信息”部分中看到“ .NET for Windows应用商店应用程序,受支持:Windows 8”。 将其与可用的 BinaryReader进行对比。

Windows.Storage 命名空间具有用于Windows 8应用程序中文件系统访问的API。

要在创建,修改或删除文件或文件夹时得到通知,可以使用Windows.Storage.Search.StorageFolderQueryResultWindows.Storage.Search.StorageFileQueryResult类以及ContentsChanged事件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM