Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 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);
         }
     }
 }
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 4
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);
			}
		}
Exemplo n.º 5
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);
     }
 }