0
ファイルシステムモニタがフォルダに追加された最初のファイルを検出しませんでしたが、FileSystemWatcherは、2回目の変更後にイベントを発生させますが、最初ではありません。
私が見ているフォルダは、ネットワーク共有にあります。
コード:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace RTTService
{
class FileSystemMonitors : IDisposable
{
FileSystemWatcher WatchFolder = new FileSystemWatcher();
public void StartMonitoringDropFolder()
{
WatchFolder.Path = @"\\<<NETWORKED SHARE>>\inetpub\mailroot\";
WatchFolder.NotifyFilter = WatchFolder.NotifyFilter | NotifyFilters.FileName;
WatchFolder.NotifyFilter = WatchFolder.NotifyFilter | NotifyFilters.Attributes;
WatchFolder.Created += new FileSystemEventHandler(WatchFolder_Action);
WatchFolder.Deleted += new FileSystemEventHandler(WatchFolder_Action);
WatchFolder.Changed += new FileSystemEventHandler(WatchFolder_Action);
WatchFolder.EnableRaisingEvents = true;
}
void WatchFolder_Action(object sender, FileSystemEventArgs e)
{
if (e.ChangeType == WatcherChangeTypes.Changed)
{
using (Email Email = new Email())
{
Email.ParseInterpretStoreDropFolderForAllMessages(false, false, false);
}
}
}
public void Dispose()
{
WatchFolder.Dispose();
}
}
}
'e(e.ChangeType == ...)の前に' e.FullPath'と 'e.ChangeType'を含む行を記録するとどうなりますか?この動作は私にとっては再現性がありません。それは通常のWindows共有ですか、あるいはSaMBaの実装ですか? – CodeCaster
なぜあなたは探していますか?あなたが作成したいときに変更されましたか? –
アイテムがフォルダに追加されたときに、作成されたイベントが発生しなかったため、作成済みではなく変更済みを使用しました。しかし、変更されたイベントがあった。編集:これはWindowsの共有です。 –