Exemple #1
0
        public void Refresh()
        {
            try
            {
                NativeMethods.WIN32_FIND_DATA findData;

                // TODO: BeginFind fails on "\\?\c:\"
                using (var handle = Directory.BeginFind(GetNormalizedPathWithSearchPattern(), out findData))
                {
                    if (handle == null)
                    {
                        state     = State.Error;
                        errorCode = Marshal.GetLastWin32Error();
                    }
                    else
                    {
                        data.From(findData);
                        state = State.Initialized;
                    }
                }
            }
            catch (DirectoryNotFoundException)
            {
                state     = State.Error;
                errorCode = NativeMethods.ERROR_PATH_NOT_FOUND;
            }
            catch (Exception)
            {
                if (state != State.Error)
                {
                    Common.ThrowIOError(Marshal.GetLastWin32Error(), FullPath);
                }
            }
        }
Exemple #2
0
 public void Refresh()
 {
     try
     {
         NativeMethods.WIN32_FIND_DATA findData;
         using (var handle = Directory.BeginFind(Path.NormalizeLongPath(FullPath), out findData))
         {
             if (handle == null)
             {
                 state     = State.Error;
                 errorCode = Marshal.GetLastWin32Error();
             }
             else
             {
                 data.From(findData);
                 state = State.Initialized;
             }
         }
     }
     catch (DirectoryNotFoundException)
     {
         state     = State.Error;
         errorCode = NativeMethods.ERROR_PATH_NOT_FOUND;
     }
     catch (Exception)
     {
         if (state != State.Error)
         {
             Common.ThrowIOError(Marshal.GetLastWin32Error(), string.Empty);
         }
     }
 }
Exemple #3
0
        public void Refresh()
        {
            try
            {
                NativeMethods.WIN32_FIND_DATA findData;
                // TODO: BeginFind fails on "\\?\c:\"

                string normalizedPathWithSearchPattern = Path.NormalizeLongPath(new DirectoryInfo(FullPath).Parent == null ? Path.Combine(FullPath, "*") : FullPath);

                using (var handle = Directory.BeginFind(normalizedPathWithSearchPattern, out findData))
                {
                    if (handle == null)
                    {
                        state     = State.Error;
                        errorCode = Marshal.GetLastWin32Error();
                    }
                    else
                    {
                        data.From(findData);
                        state = State.Initialized;
                    }
                }
            }
            catch (DirectoryNotFoundException)
            {
                state     = State.Error;
                errorCode = NativeMethods.ERROR_PATH_NOT_FOUND;
            }
            catch (Exception)
            {
                if (state != State.Error)
                {
                    Common.ThrowIOError(Marshal.GetLastWin32Error(), string.Empty);
                }
            }
        }
		public void Refresh()
		{
			try
			{
				NativeMethods.WIN32_FIND_DATA findData;
				// TODO: BeginFind fails on "\\?\c:\"

				string normalizedPathWithSearchPattern = Path.NormalizeLongPath(new DirectoryInfo(FullPath).Parent == null ? Path.Combine(FullPath, "*") : FullPath);

				using (var handle = Directory.BeginFind(normalizedPathWithSearchPattern, out findData))
				{
					if (handle == null)
					{
						state = State.Error;
						errorCode = Marshal.GetLastWin32Error();
					}
					else
					{
						data.From(findData);
						state = State.Initialized;
					}
				}
			}
			catch (DirectoryNotFoundException)
			{
				state = State.Error;
				errorCode = NativeMethods.ERROR_PATH_NOT_FOUND;
			}
			catch (Exception)
			{
				if (state != State.Error)
					Common.ThrowIOError(Marshal.GetLastWin32Error(), string.Empty);
			}
		}
 public void Refresh()
 {
     try
     {
         NativeMethods.WIN32_FIND_DATA findData;
         using (var handle = Directory.BeginFind(Path.NormalizeLongPath(FullPath), out findData))
         {
             if (handle == null)
             {
                 state = State.Error;
                 errorCode = Marshal.GetLastWin32Error();
             }
             else
             {
                 data.From(findData);
                 state = State.Initialized;
             }
         }
     }
     catch (DirectoryNotFoundException)
     {
         state = State.Error;
         errorCode = NativeMethods.ERROR_PATH_NOT_FOUND;
     }
     catch (Exception)
     {
         if (state != State.Error)
             Common.ThrowIOError(Marshal.GetLastWin32Error(), string.Empty);
     }
 }