当前位置: 首页>>代码示例>>C#>>正文


C# WIN32_FIND_DATA类代码示例

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


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


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