• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# WIN32_FIND_DATA类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中WIN32_FIND_DATA的典型用法代码示例。如果您正苦于以下问题:C# WIN32_FIND_DATA类的具体用法?C# WIN32_FIND_DATA怎么用?C# WIN32_FIND_DATA使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WIN32_FIND_DATA类属于命名空间,在下文中一共展示了WIN32_FIND_DATA类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: FindFirstFile

        internal static SafeFindHandle FindFirstFile(string fileName, ref WIN32_FIND_DATA data)
        {
            fileName = PathInternal.EnsureExtendedPrefixOverMaxPath(fileName);

            // use FindExInfoBasic since we don't care about short name and it has better perf
            return FindFirstFileExPrivate(fileName, FINDEX_INFO_LEVELS.FindExInfoBasic, ref data, FINDEX_SEARCH_OPS.FindExSearchNameMatch, IntPtr.Zero, 0);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:7,代码来源:Interop.FindFirstFileEx.cs


示例2: WIN32_FIND_DATA

 private IEnumerable<string>GetFiles(string dir)
 {
     WIN32_FIND_DATA findFileData = new WIN32_FIND_DATA();
       IntPtr h = FindFirstFile(dir, ref findFileData);
       if (h == INVALID_HANDLE_VALUE) {
     yield break;
       }
       try {
     do {
       if (findFileData.cFileName == "." || findFileData.cFileName == "..") {
     continue;
       }
       if ((findFileData.dwFileAttributes & 0x00000010u) == 0) {
     yield return findFileData.cFileName;
       }
       else {
     yield return string.Concat(findFileData.cFileName, "\\");
       }
     } while (FindNextFile(h, ref findFileData) != 0);
       }
       finally {
     if ((int)h > 0) {
       int ret = FindClose(h);
       if (ret == 0) {
     throw new Exception();
       }
     }
       }
 }
开发者ID:hazychill,项目名称:oog,代码行数:29,代码来源:DirectoryTreeView.cs


示例3: subObjectExists

 private bool subObjectExists(bool fDirectory) {
     if(hFindFile != INVALID_HANDLE_VALUE) {
         if((fDirectory && fSubDirectoryFound) || (!fDirectory && fSubFileFound)) {
             return true;
         }
         if(iLastError == 0x12) {
             return false;
         }
         int num = 0;
         WIN32_FIND_DATA lpFindFileData = new WIN32_FIND_DATA();
         int uMode = SetErrorMode(1);
         try {
             if(hFindFile == IntPtr.Zero) {
                 hFindFile = FindFirstFile(path, lpFindFileData);
             }
             if(hFindFile != INVALID_HANDLE_VALUE) {
                 do {
                     if(((lpFindFileData.cFileName != null) && (lpFindFileData.cFileName != ".")) && (lpFindFileData.cFileName != "..")) {
                         if((fSearchHidden || ((lpFindFileData.dwFileAttributes & 2) == 0)) && (fSearchSystem || ((lpFindFileData.dwFileAttributes & 4) == 0))) {
                             if((lpFindFileData.dwFileAttributes & 0x10) != 0) {
                                 fSubDirectoryFound = true;
                                 if(fDirectory) {
                                     return true;
                                 }
                             }
                             else {
                                 fSubFileFound = true;
                                 if(!fDirectory) {
                                     return true;
                                 }
                             }
                         }
                         if(++num > 0x20) {
                             if(fDirectory) {
                                 fSubDirectoryFound = true;
                             }
                             else {
                                 fSubFileFound = true;
                             }
                             return true;
                         }
                     }
                 }
                 while(FindNextFile(hFindFile, lpFindFileData));
                 iLastError = Marshal.GetLastWin32Error();
             }
         }
         finally {
             SetErrorMode(uMode);
         }
     }
     return false;
 }
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:53,代码来源:FindFile.cs


示例4: PopulateFrom

 internal void PopulateFrom(ref WIN32_FIND_DATA findData)
 {
     // Copy the information to data
     fileAttributes = (int)findData.dwFileAttributes;
     ftCreationTimeLow = findData.ftCreationTime.dwLowDateTime;
     ftCreationTimeHigh = findData.ftCreationTime.dwHighDateTime;
     ftLastAccessTimeLow = findData.ftLastAccessTime.dwLowDateTime;
     ftLastAccessTimeHigh = findData.ftLastAccessTime.dwHighDateTime;
     ftLastWriteTimeLow = findData.ftLastWriteTime.dwLowDateTime;
     ftLastWriteTimeHigh = findData.ftLastWriteTime.dwHighDateTime;
     fileSizeHigh = findData.nFileSizeHigh;
     fileSizeLow = findData.nFileSizeLow;
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:13,代码来源:Interop.GetFileAttributesEx.cs


示例5: FileData

    /// <summary>
    /// Initializes a new instance of the <see cref="FileData"/> class.
    /// </summary>
    /// <param name="dir">The directory that the file is stored at</param>
    /// <param name="findData">WIN32_FIND_DATA structure that this
    /// object wraps.</param>
    internal FileData(string dir, WIN32_FIND_DATA findData) 
    {
        this.Attributes = findData.dwFileAttributes;


        this.CreationTimeUtc = ConvertDateTime(findData.ftCreationTime_dwHighDateTime, 
            findData.ftCreationTime_dwLowDateTime);

        this.LastAccessTimeUtc = ConvertDateTime(findData.ftLastAccessTime_dwHighDateTime,
            findData.ftLastAccessTime_dwLowDateTime);

        this.LastWriteTimeUtc = ConvertDateTime(findData.ftLastWriteTime_dwHighDateTime,
            findData.ftLastWriteTime_dwLowDateTime);

        this.Size = CombineHighLowInts(findData.nFileSizeHigh, findData.nFileSizeLow);

        this.Name = findData.cFileName;
        this.Path = System.IO.Path.Combine(dir, findData.cFileName);
    }
开发者ID:InvertGames,项目名称:uFrame.Editor,代码行数:25,代码来源:FileData.cs


示例6: GetRemovableStorageDirectory

      public static string GetRemovableStorageDirectory()
      {
         string removableStorageDirectory = null;
         IntPtr handle = IntPtr.Zero;
         try
         {
            WIN32_FIND_DATA findData = new WIN32_FIND_DATA();

            handle = FindFirstFlashCard(ref findData);

            if(handle != INVALID_HANDLE_VALUE)
            {
               do
               {
                  if(!string.IsNullOrEmpty(findData.cFileName))
                  {
                     removableStorageDirectory = findData.cFileName;
                     break;
                  }
               }
               while(FindNextFlashCard(handle, ref findData));
            }
         }
         catch
         {
            removableStorageDirectory = null;
         }
         finally
         {
            if(handle != INVALID_HANDLE_VALUE)
            {
               FindClose(handle);
            }
         }
         return removableStorageDirectory;
      }
开发者ID:chharam,项目名称:Capstone_IPM_RV,代码行数:36,代码来源:Native.cs


示例7: FindFirstFlashCard

 extern static IntPtr FindFirstFlashCard(ref WIN32_FIND_DATA findData);
开发者ID:chharam,项目名称:Capstone_IPM_RV,代码行数:1,代码来源:Native.cs


示例8: FindFirstFileExPrivate

 private static extern SafeFindHandle FindFirstFileExPrivate(string lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, ref WIN32_FIND_DATA lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, IntPtr lpSearchFilter, int dwAdditionalFlags);
开发者ID:dotnet,项目名称:corefx,代码行数:1,代码来源:Interop.FindFirstFileEx.cs


示例9: FindFirstFileEx

 public static extern SafeFindFilesHandle FindFirstFileEx(string lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, out WIN32_FIND_DATA lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, IntPtr lpSearchFilter, FindFirstFileExFlags dwAdditionalFlags);
开发者ID:vcsjones,项目名称:pinvoke,代码行数:1,代码来源:Kernel32.cs


示例10: FindNextFile

 public static extern bool FindNextFile(SafeFindFilesHandle hFindFile, out WIN32_FIND_DATA lpFindFileData);
开发者ID:Eucaly,项目名称:pinvoke,代码行数:1,代码来源:Kernel32.cs


示例11: FindNextFile

 internal static extern bool FindNextFile(
             SafeFindHandle hndFindFile,
             ref WIN32_FIND_DATA lpFindFileData);
开发者ID:gitter-badger,项目名称:corefx,代码行数:3,代码来源:Interop.Windows.cs


示例12: InternetFindNextFile

//UPGRADE_WARNING: Structure WIN32_FIND_DATA may require marshalling attributes to be passed as an argument in this Declare statement. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
		public static extern int InternetFindNextFile(int hFind, ref WIN32_FIND_DATA lpvFindData);
开发者ID:nodoid,项目名称:PointOfSale,代码行数:2,代码来源:Module1.cs


示例13: FindFiles

        public static IEnumerable<string> FindFiles(DirectoryInfo dir, 
            string pattern, SearchOption searchOption)
        {
            // We suppressed this demand for each p/invoke call, so demand it upfront once
            new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();

            // Validate parameters
            if (dir == null)
                throw new ArgumentNullException("dir");
            if (pattern == null)
                throw new ArgumentNullException("pattern");

            // Setup
            WIN32_FIND_DATA findData = new WIN32_FIND_DATA();
            Stack<DirectoryInfo> directories = new Stack<DirectoryInfo>();
            directories.Push(dir);

            // Process each directory
            ErrorModes origErrorMode = SetErrorMode(ErrorModes.FailCriticalErrors);
            try
            {
                while (directories.Count > 0)
                {
                    // Get the name of the next directory and the corresponding search pattern
                    dir = directories.Pop();
                    string dirPath = dir.FullName.Trim();
                    if (dirPath.Length == 0)
                        continue;
                    char lastChar = dirPath[dirPath.Length - 1];
                    if (lastChar != Path.DirectorySeparatorChar &&
                        lastChar != Path.AltDirectorySeparatorChar)
                    {
                        dirPath += Path.DirectorySeparatorChar;
                    }

                    // Process all files in that directory
                    SafeFindHandle handle = FindFirstFile(dirPath + pattern, findData);
                    if (handle.IsInvalid)
                    {
                        int error = Marshal.GetLastWin32Error();
                        if (error == ERROR_ACCESS_DENIED ||
                            error == ERROR_FILE_NOT_FOUND)
                        {
                            continue;
                        }
                        else
                        {
                            throw new Win32Exception(error);
                        }
                    }
                    else
                    {
                        try
                        {
                            do
                            {
                                if ((findData.dwFileAttributes &
                                    FileAttributes.Directory) == 0)
                                    yield return (dirPath + findData.cFileName);
                            }
                            while (FindNextFile(handle, findData));
                            int error = Marshal.GetLastWin32Error();
                            if (error != ERROR_NO_MORE_FILES)
                            {
                                throw new Win32Exception(error);
                            }
                        }
                        finally
                        {
                            handle.Dispose();
                        }
                    }

                    // Add all child directories if that's what the user wants
                    if (searchOption == SearchOption.AllDirectories)
                    {
                        foreach (DirectoryInfo childDir in dir.GetDirectories())
                        {
                            if ((File.GetAttributes(childDir.FullName) &
                                FileAttributes.ReparsePoint) == 0)
                            {
                                directories.Push(childDir);
                            }
                        }
                    }
                }
            }
            finally
            {
                SetErrorMode(origErrorMode);
            }
        }
开发者ID:udayanroy,项目名称:SvgSharp,代码行数:92,代码来源:DirectoryUtils.cs


示例14: FindFirstFile

 private static extern IntPtr FindFirstFile(string lpFileName,
     out WIN32_FIND_DATA lpFindFileData);
开发者ID:padgettrowell,项目名称:CowboyFS,代码行数:2,代码来源:FileSystemEnumerator.cs


示例15: FindFirstFile

 private static extern IntPtr FindFirstFile([MarshalAs(UnmanagedType.VBByRefStr)] ref string lpFileName, ref WIN32_FIND_DATA lpFindFileData);
开发者ID:vardars,项目名称:ci-factory,代码行数:1,代码来源:LogFile.cs


示例16: FindNextFile

 internal static extern bool FindNextFile(
             IntPtr hndFindFile, out WIN32_FIND_DATA pFindFileData);
开发者ID:uQr,项目名称:referencesource,代码行数:2,代码来源:UnsafeNativeMethods.cs


示例17: FindFirstFileTransactedW

		private SafeFindHandle FindFirstFileTransactedW(string lpFileName,
		                                                out WIN32_FIND_DATA lpFindFileData)
		{
			return FindFirstFileTransactedW(lpFileName, FINDEX_INFO_LEVELS.FindExInfoStandard,
			                                out lpFindFileData, 
			                                FINDEX_SEARCH_OPS.FindExSearchNameMatch, 
			                                IntPtr.Zero, 0,
			                                _TransactionHandle);
		}
开发者ID:gongzunpan,项目名称:infrastructure,代码行数:9,代码来源:FileTransaction.cs


示例18: FindFirstFile

 internal static extern IntPtr FindFirstFile(
             string pFileName, out WIN32_FIND_DATA pFindFileData);
开发者ID:uQr,项目名称:referencesource,代码行数:2,代码来源:UnsafeNativeMethods.cs


示例19: EnumDirectoryEntries

        public static IEnumerable<DirectoryEntry> EnumDirectoryEntries(string path, string searchPattern, bool recursive, Func<uint, bool> attributeFilter)
        {
            #if !WINDOWS
            throw new NotImplementedException();
            #else
            if (!System.IO.Directory.Exists(path))
                throw new System.IO.DirectoryNotFoundException();

            var buffer = new StringBuilder();
            string actualPath = System.IO.Path.GetFullPath(path + @"\");
            var patterns = searchPattern.Split(';');
            var globs = (from p in patterns select GlobToRegex(p)).ToArray();
            var findData = new WIN32_FIND_DATA();
            var searchPaths = new Queue<string>();
            var entry = new DirectoryEntry();
            searchPaths.Enqueue("");

            while (searchPaths.Count != 0) {
                string currentPath = searchPaths.Dequeue();

                buffer.Remove(0, buffer.Length);
                buffer.Append(actualPath);
                buffer.Append(currentPath);
                buffer.Append("*");

                using (var handle = new FindHandle(FindFirstFile(buffer.ToString(), out findData)))
                while (handle.Valid) {
                    string fileName = findData.cFileName;

                    if ((fileName != ".") && (fileName != "..")) {
                        bool isDirectory = (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY;
                        bool masked = !attributeFilter(findData.dwFileAttributes);

                        buffer.Remove(0, buffer.Length);
                        buffer.Append(actualPath);
                        buffer.Append(currentPath);
                        buffer.Append(fileName);

                        if (isDirectory)
                            buffer.Append("\\");

                        if (recursive && isDirectory) {
                            var subdir = buffer.ToString().Substring(actualPath.Length);
                            searchPaths.Enqueue(subdir);
                        }

                        if (!masked) {
                            string fileNameLower = fileName.ToLower();

                            bool globMatch = false;
                            foreach (var glob in globs) {
                                if (glob.IsMatch(fileNameLower)) {
                                    globMatch = true;
                                    break;
                                }
                            }

                            if (globMatch) {
                                entry.Name = buffer.ToString();
                                entry.Attributes = findData.dwFileAttributes;
                                entry.Size = findData.dwFileSizeLow + (findData.dwFileSizeHigh * ((ulong)(UInt32.MaxValue) + 1));
                                entry.Created = findData.ftCreationTime;
                                entry.LastAccessed = findData.ftLastAccessTime;
                                entry.LastWritten = findData.ftLastWriteTime;
                                entry.IsDirectory = isDirectory;
                                yield return entry;
                            }
                        }
                    }

                    if (!FindNextFile(handle, out findData))
                        break;
                }
            }
            #endif
        }
开发者ID:sq,项目名称:Fracture,代码行数:76,代码来源:IO.cs


示例20: FtpFindFirstFile

//UPGRADE_WARNING: Structure WIN32_FIND_DATA may require marshalling attributes to be passed as an argument in this Declare statement. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
		public static extern int FtpFindFirstFile(int hFtpSession, string lpszSearchFile, ref WIN32_FIND_DATA lpFindFileData, int dwFlags, int dwContent);
开发者ID:nodoid,项目名称:PointOfSale,代码行数:2,代码来源:Module1.cs



注:本文中的WIN32_FIND_DATA类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# WINDOWPLACEMENT类代码示例发布时间:2022-05-24
下一篇:
C# WIGStartInfo类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap