èæ¯
ç±äºæä»¬å ¬å¸ä¸åé¨é¨æä»¶é½æ¾å¨å ±äº«çä¸ï¼æä»¬éè¦å°å ¬çæä»¶ä¸ä¼ é¿éäºæftpï¼åå¢éæ¥è¯¢ï¼ä¸ä¼ è¿çæ°æ®ä¸ä¼å¨ä¸ä¼ ï¼
ç±äºæ«æå ¬çéæ±è¶æ¥è¶å¤ï¼æ°æ®éè¶æ¥è¶å¤§ï¼ä¹åéè¿é彿«æç£ççæ¹å¼å¤ªæ ¢ã
æä»¥ç ç©¶éè¿everythingæç´¢æä»¶æ¹å¼æ¿æ¢ä¹åçæ¹å¼ã ç ç©¶ä¸æ¥åç°è¯¥æ¹å¼æ«æç£çé度é常快ã
é£ä¹åºè¯ä¸å¤è¯´ï¼ç´æ¥ä¸ä»£ç ã
Â
妿éè¦æ«æå ±äº«ççè¯:
(å¦ææ¯æ¬å°ç£çå¯ä»¥å¿½ç¥1)
1.éè¦å®è£ ä¸ä¸everythingï¼å¨é项-æä»¶å¤¹-æ·»å ä¸ä¸ä½ çæä»¶ç®å½
2.éè¦å°Everything32.dll copyå°ä½ çbinç®å½ä¸
3.å¯ä»¥copy代ç ï¼è¿è¡
[DllImport("Everything32.dll", CharSet = CharSet.Unicode)]
public static extern int Everything_SetSearchW(string lpSearchString);
[DllImport("Everything32.dll")]
public static extern void Everything_SetMatchPath(bool bEnable);
[DllImport("Everything32.dll")]
public static extern void Everything_SetMatchCase(bool bEnable);
[DllImport("Everything32.dll")]
public static extern void Everything_SetMatchWholeWord(bool bEnable);
[DllImport("Everything32.dll")]
public static extern void Everything_SetRegex(bool bEnable);
[DllImport("Everything32.dll")]
public static extern void Everything_SetMax(int dwMax);
[DllImport("Everything32.dll")]
public static extern void Everything_SetOffset(int dwOffset);
[DllImport("Everything32.dll")]
public static extern void Everything_SetReplyWindow(IntPtr hWnd);
[DllImport("Everything32.dll")]
public static extern void Everything_SetReplyID(int nId);
[DllImport("Everything32.dll")]
public static extern bool Everything_GetMatchPath();
[DllImport("Everything32.dll")]
public static extern bool Everything_GetMatchCase();
[DllImport("Everything32.dll")]
public static extern bool Everything_GetMatchWholeWord();
[DllImport("Everything32.dll")]
public static extern bool Everything_GetRegex();
[DllImport("Everything32.dll")]
public static extern UInt32 Everything_GetMax();
[DllImport("Everything32.dll")]
public static extern UInt32 Everything_GetOffset();
[DllImport("Everything32.dll")]
public static extern string Everything_GetSearch();
[DllImport("Everything32.dll")]
public static extern int Everything_GetLastError();
[DllImport("Everything32.dll")]
public static extern IntPtr Everything_GetReplyWindow();
[DllImport("Everything32.dll")]
public static extern int Everything_GetReplyID();
[DllImport("Everything32.dll")]
public static extern bool Everything_QueryW(bool bWait);
[DllImport("Everything32.dll")]
public static extern bool Everything_IsQueryReply(int message, IntPtr wParam, IntPtr lParam, uint nId);
[DllImport("Everything32.dll")]
public static extern void Everything_SortResultsByPath();
[DllImport("Everything32.dll")]
public static extern int Everything_GetNumFileResults();
[DllImport("Everything32.dll")]
public static extern int Everything_GetNumFolderResults();
[DllImport("Everything32.dll")]
public static extern int Everything_GetNumResults();
[DllImport("Everything32.dll")]
public static extern int Everything_GetTotFileResults();
[DllImport("Everything32.dll")]
public static extern int Everything_GetTotFolderResults();
[DllImport("Everything32.dll")]
public static extern int Everything_GetTotResults();
[DllImport("Everything32.dll")]
public static extern bool Everything_IsVolumeResult(int nIndex);
[DllImport("Everything32.dll")]
public static extern bool Everything_IsFolderResult(int nIndex);
[DllImport("Everything32.dll")]
public static extern bool Everything_IsFileResult(int nIndex);
[DllImport("Everything32.dll", CharSet = CharSet.Unicode)]
public static extern void Everything_GetResultFullPathNameW(int nIndex, StringBuilder lpString, int nMaxCount);
[DllImport("Everything32.dll")]
public static extern void Everything_Reset();
#region Enum
enum StateCode
{
OK,
MemoryError,
IPCError,
RegisterClassExError,
CreateWindowError,
CreateThreadError,
InvalidIndexError,
InvalidCallError
}
#endregion
#region Property
/// <summary>
/// Gets or sets a value indicating whether [match path].
/// </summary>
/// <value><c>true</c> if [match path]; otherwise, <c>false</c>.</value>
public Boolean MatchPath
{
get
{
return Everything_GetMatchPath();
}
set
{
Everything_SetMatchPath(value);
}
}
/// <summary>
/// Gets or sets a value indicating whether [match case].
/// </summary>
/// <value><c>true</c> if [match case]; otherwise, <c>false</c>.</value>
public Boolean MatchCase
{
get
{
return Everything_GetMatchCase();
}
set
{
Everything_SetMatchCase(value);
}
}
/// <summary>
/// Gets or sets a value indicating whether [match whole word].
/// </summary>
/// <value><c>true</c> if [match whole word]; otherwise, <c>false</c>.</value>
public Boolean MatchWholeWord
{
get
{
return Everything_GetMatchWholeWord();
}
set
{
Everything_SetMatchWholeWord(value);
}
}
/// <summary>
/// Gets or sets a value indicating whether [enable regex].
/// </summary>
/// <value><c>true</c> if [enable regex]; otherwise, <c>false</c>.</value>
public Boolean EnableRegex
{
get
{
return Everything_GetRegex();
}
set
{
Everything_SetRegex(value);
}
}
#endregion
#region Public Method
/// <summary>
/// Resets this instance.
/// </summary>
public void Reset()
{
Everything_Reset();
}
/// <summary>
/// Searches the specified key word.
/// </summary>
/// <param name="keyWord">The key word.</param>
/// <returns></returns>
public static IEnumerable<string> Search(string keyWord)
{
return Search(keyWord, 0, int.MaxValue);
}
/// <summary>
/// Searches the specified key word.
/// </summary>
/// <param name="keyWord">The key word.</param>
/// <param name="offset">The offset.</param>
/// <param name="maxCount">The max count.</param>
/// <returns></returns>
public static IEnumerable<string> Search(string keyWord, int offset, int maxCount)
{
if (string.IsNullOrEmpty(keyWord))
throw new ArgumentNullException("keyWord");
if (offset < 0)
throw new ArgumentOutOfRangeException("offset");
if (maxCount < 0)
throw new ArgumentOutOfRangeException("maxCount");
Everything_SetSearchW(keyWord);
Everything_SetOffset(offset);
Everything_SetMax(maxCount);
if (!Everything_QueryW(true))
{
switch (Everything_GetLastError())
{
case (int)StateCode.CreateThreadError:
throw new CreateThreadException();
case (int)StateCode.CreateWindowError:
throw new CreateWindowException();
case (int)StateCode.InvalidCallError:
throw new InvalidCallException();
case (int)StateCode.InvalidIndexError:
throw new InvalidIndexException();
case (int)StateCode.IPCError:
throw new IPCErrorException();
case (int)StateCode.MemoryError:
throw new MemoryErrorException();
case (int)StateCode.RegisterClassExError:
throw new RegisterClassExException();
}
yield break;
}
const int bufferSize = 256;
StringBuilder buffer = new StringBuilder(bufferSize);
for (int idx = 0; idx < Everything_GetNumResults(); ++idx)
{
Everything_GetResultFullPathNameW(idx, buffer, bufferSize);
yield return buffer.ToString();
}
}
#endregion
/// <summary>
/// /// </summary>
public class MemoryErrorException : ApplicationException
{
}
/// <summary>
/// /// </summary>
public class IPCErrorException : ApplicationException
{
}
/// <summary>
/// /// </summary>
public class RegisterClassExException : ApplicationException
{
}
/// <summary>
/// /// </summary>
public class CreateWindowException : ApplicationException
{
}
/// <summary>
/// /// </summary>
public class CreateThreadException : ApplicationException
{
}
/// <summary>
/// /// </summary>
public class InvalidIndexException : ApplicationException
{
}
/// <summary>
/// /// </summary>
public class InvalidCallException : ApplicationException
{
}
static void Main(string[] args)
{
//@"\\10.10.1.10\æä»¶å¤¹åç§° <*.png|jpg|bmp>" æ"c:<*.png|jpg|bmp> dm:2019/5-2019/12为ä¸ä¸ªæ¶é´æ®µå
çæä»¶
var list = Search(@"æä»¶åæç®å½");
ArrayList array = new ArrayList();
foreach (var item in list)
{
array.Add(item);
}
}
è¿åçç»æå°±æ¯ä½ è¦ä¸ä¼ çæä»¶å表ï¼å¦ææéè¦å¯ä»¥æ ¹æ®èªå·±ç鿱卿¬¡æå±ã