Ejemplo n.º 1
0
		/// <summary>
		/// Deep delete that can handle paths upto ~32k characters.
		/// </summary>
		/// <param name="path"></param>
		/// <returns></returns>
		public void ShellDeleteFile(string path)
		{	
			var shFile = new SHFILEOPSTRUCT();
			shFile.hwnd = IntPtr.Zero;
			shFile.wFunc = 0x3; // FO_DELETE
			shFile.pFrom = path;
			shFile.pTo = "";
			shFile.fAnyOperationsAborted = false;
			shFile.hNameMappings = IntPtr.Zero;
			shFile.lpszProgressTitle = "";
			shFile.fFlags = 0x10;// FOF_NOCONFIRMATION;
			// TODO handle any errors
			SHFileOperation(ref shFile);

			// in the case of a directory path, SHFileOperation will delete
			// contents but seems to leave directory itself
  			if (Directory.Exists(path)) 
			{
				Directory.Delete(path);
			}
		}
Ejemplo n.º 2
0
        /// <summary>
        /// Deep delete that can handle paths upto ~32k characters.
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public void ShellDeleteFile(string path)
        {
            var shFile = new SHFILEOPSTRUCT();

            shFile.hwnd  = IntPtr.Zero;
            shFile.wFunc = 0x3;             // FO_DELETE
            shFile.pFrom = path;
            shFile.pTo   = "";
            shFile.fAnyOperationsAborted = false;
            shFile.hNameMappings         = IntPtr.Zero;
            shFile.lpszProgressTitle     = "";
            shFile.fFlags = 0x10;            // FOF_NOCONFIRMATION;
            // TODO handle any errors
            SHFileOperation(ref shFile);

            // in the case of a directory path, SHFileOperation will delete
            // contents but seems to leave directory itself
            if (Directory.Exists(path))
            {
                Directory.Delete(path);
            }
        }
Ejemplo n.º 3
0
 static extern int SHFileOperation([In] ref SHFILEOPSTRUCT lpFileOp);