public void SetFileNotifyInformation(List <FileNotifyInformation> notifyInformationList) { FileNotifyInformationBytes = FileNotifyInformation.GetBytes(notifyInformationList); }
public List <FileNotifyInformation> GetFileNotifyInformation() { return(FileNotifyInformation.ReadList(FileNotifyInformationBytes, 0)); }
public List <FileNotifyInformation> GetFileNotifyInformation() { return(FileNotifyInformation.ReadList(OutputBuffer, 0)); }
public void SetFileNotifyInformation(List <FileNotifyInformation> notifyInformationList) { OutputBuffer = FileNotifyInformation.GetBytes(notifyInformationList); }
private unsafe void ThreadProc() { IntPtr notifyHandle = NativeMethods.FindFirstChangeNotification(m_path, true, filter); FileNotifyInformation notifyData = new FileNotifyInformation(); uint returned = 0; uint available = 0; EventWaitHandle ewh = new EventWaitHandle(false, EventResetMode.ManualReset, WaitHandleName); EventWaitHandle quitWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset, WaitHandleNameQuit); while (!m_quit) { ewh.Reset(); if (EventWaitHandle.WaitAny(new IntPtr[] { notifyHandle, ewh.Handle }, TimeoutInfinite, false) != EventWaitHandle.WaitTimeout) { if (m_quit) { break; } IntPtr ptr = IntPtr.Zero; if (NativeMethods.CeGetFileNotificationInfo(notifyHandle, 0, ref ptr, 0, ref returned, ref available)) { if (available > 0) { int maxData = 2048; fixed(byte *pData = new byte[maxData]) { // get data if (NativeMethods.CeGetFileNotificationInfo(notifyHandle, 0, pData, maxData, ref returned, ref available)) { notifyData = new FileNotifyInformation(pData, 0); // handle data in notifyData if (ValidateByFilter(notifyData.Filename)) { RaiseEvents(notifyData.Action, notifyData.Filename); } int offset = 0; offset += notifyData.NextEntryOffset; while (notifyData.NextEntryOffset > 0) { notifyData = new FileNotifyInformation(pData, offset); if (ValidateByFilter(notifyData.Filename)) { RaiseEvents(notifyData.Action, notifyData.Filename); } offset += notifyData.NextEntryOffset; } } } } else { //Seems that subdirectories don't return anything but then the notifyHandle is never reset and if available data is 0 notifyHandle never resets NativeMethods.FindCloseChangeNotification(notifyHandle); notifyHandle = NativeMethods.FindFirstChangeNotification(m_path, true, filter); } } } // if( waithandle... } // while (!m_quit) NativeMethods.FindCloseChangeNotification(notifyHandle); quitWaitHandle.Set(); }