示例#1
0
 public void SetFileNotifyInformation(List <FileNotifyInformation> notifyInformationList)
 {
     FileNotifyInformationBytes = FileNotifyInformation.GetBytes(notifyInformationList);
 }
示例#2
0
 public List <FileNotifyInformation> GetFileNotifyInformation()
 {
     return(FileNotifyInformation.ReadList(FileNotifyInformationBytes, 0));
 }
示例#3
0
 public List <FileNotifyInformation> GetFileNotifyInformation()
 {
     return(FileNotifyInformation.ReadList(OutputBuffer, 0));
 }
示例#4
0
 public void SetFileNotifyInformation(List <FileNotifyInformation> notifyInformationList)
 {
     OutputBuffer = FileNotifyInformation.GetBytes(notifyInformationList);
 }
示例#5
0
            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();
            }