[英]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.