示例#1
0
 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();
       }
     }
       }
 }
示例#2
0
        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);
        }
示例#3
0
 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;
 }
 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;
 }
示例#5
0
    /// <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);
    }
示例#6
0
      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;
      }
		private static extern bool FindNextFile(SafeFindHandle hFindFile, 
		                                        out WIN32_FIND_DATA lpFindFileData);
示例#8
0
 public static extern SafeFindFilesHandle FindFirstFileEx(string lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, out WIN32_FIND_DATA lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, IntPtr lpSearchFilter, FindFirstFileExFlags dwAdditionalFlags);
示例#9
0
        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);
            }
        }
示例#10
0
        protected override void internal_command_proc()
        {
            var e_current = new QueryPanelInfoEventArgs();
            var e_other   = new QueryPanelInfoEventArgs();

            OnQueryCurrentPanel(e_current);
            OnQueryOtherPanel(e_other);

            if (!(e_current.ItemCollection is DirectoryList))
            {
                return;
            }

            if (!(e_other.ItemCollection is DirectoryList))
            {
                Messages.ShowMessage(Options.GetLiteral(Options.LANG_WRONG_DESTINATION));
                return;
            }

            if (e_current.FocusedIndex == -1)
            {
                return;
            }

            var dl_current = (DirectoryList)e_current.ItemCollection;
            var dl_other   = (DirectoryList)e_other.ItemCollection;
            var group_mode = e_current.SelectedIndices.Length > 1;
            var link_type  = Options.LinkType;

            var sels = new List <FileInfoEx>();

            if (e_current.SelectedIndices.Length > 0)
            {
                for (var i = 0; i < e_current.SelectedIndices.Length; i++)
                {
                    sels.Add(dl_current[e_current.SelectedIndices[i]]);
                }
            }
            else
            {
                sels.Add(dl_current[e_current.FocusedIndex]);
            }

            //show dialog
            var dialog = new CreateLinkDialog();

            dialog.Text                 = Options.GetLiteral(Options.LANG_LINK_CREATE);
            dialog.LinkType             = link_type;
            dialog.textBoxLinkname.Text = string.Empty;
            if (group_mode)
            {
                dialog.textBoxLinkname.ReadOnly = true;
                dialog.textBoxLinktarget.Text   = string.Format
                                                      ("{0} " + Options.GetLiteral(Options.LANG_ENTRIES),
                                                      sels.Count);
            }
            else
            {
                dialog.textBoxLinktarget.Text = sels[0].FileName;
            }

            if (dialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            link_type        = dialog.LinkType;
            Options.LinkType = link_type;

            foreach (var entry in sels)
            {
                var link_handle = IntPtr.Zero;
                //combine link name
                var link_name = string.Empty;
                if (dialog.textBoxLinkname.Text == string.Empty)
                {
                    //use target file name
                    link_name = Path.Combine(dl_other.DirectoryPath, entry.FileName);
                }
                else
                {
                    link_name = Path.Combine(dl_other.DirectoryPath, dialog.textBoxLinkname.Text);
                }

                try
                {
                    if ((entry.Directory) && (link_type == NTFSlinkType.Hard))
                    {
                        Messages.ShowMessage
                            (string.Format
                                (Options.GetLiteral(Options.LANG_CANNOT_CREATE_HARD_LINK_DIR_0),
                                entry.FullName));
                        continue;
                    }

                    if (link_type == NTFSlinkType.Hard)
                    {
                        var res = WinApiFS.CreateHardLink
                                      (link_name,
                                      entry.FullName,
                                      IntPtr.Zero);
                        if (res == 0)
                        {
                            Messages.ShowException
                                (new Win32Exception(Marshal.GetLastWin32Error()),
                                string.Format
                                    (Options.GetLiteral(Options.LANG_CANNOT_CREATE_LINK_0_ARROW_1),
                                    entry.FullName,
                                    link_name));
                        }
                        else
                        {
                            OnItemProcessDone(new ItemEventArs(entry.FileName));
                        }
                        continue;
                    }

                    if (link_type == NTFSlinkType.Symbolic)
                    {
                        try
                        {
                            WinAPiFSwrapper.CreateSymbolicLink(link_name, entry.FullName, entry.Directory);
                            OnItemProcessDone(new ItemEventArs(entry.FileName));
                        }
                        catch (Exception)
                        {
                            Messages.ShowException
                                (new Win32Exception(Marshal.GetLastWin32Error()),
                                string.Format
                                    (Options.GetLiteral(Options.LANG_CANNOT_CREATE_LINK_0_ARROW_1),
                                    entry.FullName,
                                    link_name));
                        }
                        continue;
                    }

                    //link type is junction

                    var link_data  = new WIN32_FIND_DATA();
                    var link_exist = WinAPiFSwrapper.GetFileInfo(link_name, ref link_data);

                    if (link_exist)
                    {
                        Messages.ShowMessage(string.Format(Options.GetLiteral(Options.LANG_DESTINATION_0_EXIST_OVERWRITING_PROHIBITED), link_name));
                        continue;
                    }

                    //jumction target must be directory, create directory
                    Directory.CreateDirectory(link_name);
                    //and retrieve handle
                    link_handle = WinApiFS.CreateFile_intptr
                                      (link_name,
                                      Win32FileAccess.WRITE_ATTRIBUTES | Win32FileAccess.WRITE_EA,
                                      FileShare.ReadWrite,
                                      IntPtr.Zero,
                                      FileMode.Open,
                                      CreateFileOptions.OPEN_REPARSE_POINT | CreateFileOptions.BACKUP_SEMANTICS,
                                      IntPtr.Zero);
                    if (link_handle.ToInt64() == WinApiFS.INVALID_HANDLE_VALUE)
                    {
                        var win_ex = new Win32Exception(Marshal.GetLastWin32Error());
                        Messages.ShowException
                            (win_ex,
                            string.Format
                                (Options.GetLiteral(Options.LANG_CANNOT_CREATE_LINK_0_ARROW_1),
                                link_name,
                                entry.FullName));
                        if (Directory.Exists(link_name))
                        {
                            Directory.Delete(link_name);
                        }
                        continue;
                    }
                    //now handle to link open
                    WinAPiFSwrapper.SetMountpoint(link_handle, entry.FullName, entry.FullName);

                    OnItemProcessDone(new ItemEventArs(entry.FileName));
                }//end try
                catch (Exception ex)
                {
                    Messages.ShowException
                        (ex,
                        string.Format
                            (Options.GetLiteral(Options.LANG_CANNOT_CREATE_LINK_0_ARROW_1),
                            entry.FullName,
                            link_name));
                }
                finally
                {
                    //close handle
                    if ((link_handle.ToInt64() != WinApiFS.INVALID_HANDLE_VALUE) && (link_handle != IntPtr.Zero))
                    {
                        WinApiFS.CloseHandle(link_handle);
                    }
                }
            }//end foreach
        }
示例#11
0
 public static extern IntPtr FindFirstFile(string pFileName, ref WIN32_FIND_DATA pFindFileData);
示例#12
0
 internal static extern IntPtr FindFirstFile(String fileName, out WIN32_FIND_DATA data);
示例#13
0
 public static extern SafeFindFilesHandle FindFirstFile(string lpFileName, out WIN32_FIND_DATA lpFindFileData);
示例#14
0
 private static extern bool FindNextFile(SafeFindHandle hndFindFile, [In, Out, MarshalAs(UnmanagedType.LPStruct)] WIN32_FIND_DATA lpFindFileData);
示例#15
0
 public static extern SafeFindHandle FindFirstFileW(string lpFileName, out WIN32_FIND_DATA lpFindFileData);
示例#16
0
        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);
            }
        }
示例#17
0
 private static extern SafeFindHandle FindFirstFile(string lpFileName, [In, Out, MarshalAs(UnmanagedType.LPStruct)] WIN32_FIND_DATA lpFindFileData);
示例#18
0
 public static extern int SHGetDataFromIDListW(IShellFolder psf, IntPtr pidl, int nFormat, out WIN32_FIND_DATA pv, int cb);
示例#19
0
 internal static extern bool FindNextFile(SafeFindHandle hndFindFile, ref WIN32_FIND_DATA lpFindFileData);
示例#20
0
 public static extern bool FindNextFile(IntPtr hFindFile, ref WIN32_FIND_DATA lpFindFileData);
示例#21
0
//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);
示例#22
0
 public static extern bool FindNextFileW(SafeFindHandle hFindFile, out WIN32_FIND_DATA lpFindFileData);
示例#23
0
 internal static extern IntPtr FindFirstFile(
             string pFileName, out WIN32_FIND_DATA pFindFileData);
示例#24
0
 public static unsafe extern SafeFindFilesHandle FindFirstFileEx(string lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, out WIN32_FIND_DATA lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, void *lpSearchFilter, FindFirstFileExFlags dwAdditionalFlags);
示例#25
0
        public int FindFilesWithPatternProxy(
            IntPtr rawFileName,
			IntPtr rawSearchPattern,
            IntPtr rawFillFindData, // function pointer
            ref DOKAN_FILE_INFO rawFileInfo)
        {
            try
            {
                string file = GetFileName(rawFileName);
                string searchPattern = GetFileName(rawSearchPattern);
                var files = operations_.FindFilesWithPattern(file, searchPattern, GetFileInfo(ref rawFileInfo));

                FILL_FIND_DATA fill = (FILL_FIND_DATA)Marshal.GetDelegateForFunctionPointer(
                    rawFillFindData, typeof(FILL_FIND_DATA));

                foreach (var fi in files)
                {
                    var data = new WIN32_FIND_DATA();
                    //ZeroMemory(&data, sizeof(WIN32_FIND_DATAW));

                    data.dwFileAttributes = fi.Attributes;

                    data.ftCreationTime.dwHighDateTime = (int)(fi.CreationTime.ToFileTime() >> 32);
                    data.ftCreationTime.dwLowDateTime = (int)(fi.CreationTime.ToFileTime() & 0xffffffff);
                    data.ftLastAccessTime.dwHighDateTime = (int)(fi.LastAccessTime.ToFileTime() >> 32);
                    data.ftLastAccessTime.dwLowDateTime = (int)(fi.LastAccessTime.ToFileTime() & 0xffffffff);
                    data.ftLastWriteTime.dwHighDateTime = (int)(fi.LastWriteTime.ToFileTime() >> 32);
                    data.ftLastWriteTime.dwLowDateTime = (int)(fi.LastWriteTime.ToFileTime() & 0xffffffff);
                    data.nFileSizeLow = (uint)(fi.Length & 0xffffffff);
                    data.nFileSizeHigh = (uint)(fi.Length >> 32);

                    data.cFileName = fi.FileName;

                    fill(ref data, ref rawFileInfo);
                }

                return 0;
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                return -1;
            }
        }
        public static async Task <ListedItem> GetFile(
            WIN32_FIND_DATA findData,
            string pathRoot,
            string dateReturnFormat,
            NamedPipeAsAppServiceConnection connection,
            CancellationToken cancellationToken
            )
        {
            IUserSettingsService userSettingsService = Ioc.Default.GetService <IUserSettingsService>();

            var itemPath = Path.Combine(pathRoot, findData.cFileName);

            string itemName;

            if (userSettingsService.FilesAndFoldersSettingsService.ShowFileExtensions && !findData.cFileName.EndsWith(".lnk") && !findData.cFileName.EndsWith(".url"))
            {
                itemName = findData.cFileName; // never show extension for shortcuts
            }
            else
            {
                if (findData.cFileName.StartsWith("."))
                {
                    itemName = findData.cFileName; // Always show full name for dotfiles.
                }
                else
                {
                    itemName = Path.GetFileNameWithoutExtension(itemPath);
                }
            }

            DateTime itemModifiedDate, itemCreatedDate, itemLastAccessDate;

            try
            {
                FileTimeToSystemTime(ref findData.ftLastWriteTime, out SYSTEMTIME systemModifiedDateOutput);
                itemModifiedDate = new DateTime(
                    systemModifiedDateOutput.Year, systemModifiedDateOutput.Month, systemModifiedDateOutput.Day,
                    systemModifiedDateOutput.Hour, systemModifiedDateOutput.Minute, systemModifiedDateOutput.Second, systemModifiedDateOutput.Milliseconds,
                    DateTimeKind.Utc);

                FileTimeToSystemTime(ref findData.ftCreationTime, out SYSTEMTIME systemCreatedDateOutput);
                itemCreatedDate = new DateTime(
                    systemCreatedDateOutput.Year, systemCreatedDateOutput.Month, systemCreatedDateOutput.Day,
                    systemCreatedDateOutput.Hour, systemCreatedDateOutput.Minute, systemCreatedDateOutput.Second, systemCreatedDateOutput.Milliseconds,
                    DateTimeKind.Utc);

                FileTimeToSystemTime(ref findData.ftLastAccessTime, out SYSTEMTIME systemLastAccessOutput);
                itemLastAccessDate = new DateTime(
                    systemLastAccessOutput.Year, systemLastAccessOutput.Month, systemLastAccessOutput.Day,
                    systemLastAccessOutput.Hour, systemLastAccessOutput.Minute, systemLastAccessOutput.Second, systemLastAccessOutput.Milliseconds,
                    DateTimeKind.Utc);
            }
            catch (ArgumentException)
            {
                // Invalid date means invalid findData, do not add to list
                return(null);
            }

            long   itemSizeBytes     = findData.GetSize();
            var    itemSize          = ByteSize.FromBytes(itemSizeBytes).ToBinaryString().ConvertSizeAbbreviation();
            string itemType          = "ItemTypeFile".GetLocalized();
            string itemFileExtension = null;

            if (findData.cFileName.Contains('.'))
            {
                itemFileExtension = Path.GetExtension(itemPath);
                itemType          = itemFileExtension.Trim('.') + " " + itemType;
            }

            bool itemFolderImgVis    = false;
            bool itemThumbnailImgVis = false;
            bool itemEmptyImgVis     = true;

            if (cancellationToken.IsCancellationRequested)
            {
                return(null);
            }

            if (findData.cFileName.EndsWith(".lnk") || findData.cFileName.EndsWith(".url"))
            {
                if (connection != null)
                {
                    var(status, response) = await connection.SendMessageForResponseAsync(new ValueSet()
                    {
                        { "Arguments", "FileOperation" },
                        { "fileop", "ParseLink" },
                        { "filepath", itemPath }
                    });

                    // If the request was canceled return now
                    if (cancellationToken.IsCancellationRequested)
                    {
                        return(null);
                    }
                    if (status == AppServiceResponseStatus.Success &&
                        response.ContainsKey("TargetPath"))
                    {
                        var    isUrl  = findData.cFileName.EndsWith(".url");
                        string target = (string)response["TargetPath"];

                        bool   isHidden = (((FileAttributes)findData.dwFileAttributes & FileAttributes.Hidden) == FileAttributes.Hidden);
                        double opacity  = 1;

                        if (isHidden)
                        {
                            opacity = Constants.UI.DimItemOpacity;
                        }

                        return(new ShortcutItem(null, dateReturnFormat)
                        {
                            PrimaryItemAttribute = (bool)response["IsFolder"] ? StorageItemTypes.Folder : StorageItemTypes.File,
                            FileExtension = itemFileExtension,
                            IsHiddenItem = isHidden,
                            Opacity = opacity,
                            FileImage = null,
                            LoadFileIcon = !(bool)response["IsFolder"] && itemThumbnailImgVis,
                            LoadUnknownTypeGlyph = !(bool)response["IsFolder"] && !isUrl && itemEmptyImgVis,
                            LoadWebShortcutGlyph = !(bool)response["IsFolder"] && isUrl && itemEmptyImgVis,
                            LoadFolderGlyph = (bool)response["IsFolder"],
                            ItemName = itemName,
                            ItemDateModifiedReal = itemModifiedDate,
                            ItemDateAccessedReal = itemLastAccessDate,
                            ItemDateCreatedReal = itemCreatedDate,
                            ItemType = isUrl ? "ShortcutWebLinkFileType".GetLocalized() : "ShortcutFileType".GetLocalized(),
                            ItemPath = itemPath,
                            FileSize = itemSize,
                            FileSizeBytes = itemSizeBytes,
                            TargetPath = target,
                            Arguments = (string)response["Arguments"],
                            WorkingDirectory = (string)response["WorkingDirectory"],
                            RunAsAdmin = (bool)response["RunAsAdmin"],
                            IsUrl = isUrl,
                        });
                    }
                }
            }
            else if (App.LibraryManager.TryGetLibrary(itemPath, out LibraryLocationItem library))
            {
                return(new LibraryItem(library)
                {
                    ItemDateModifiedReal = itemModifiedDate,
                    ItemDateCreatedReal = itemCreatedDate,
                });
            }
            else
            {
                bool   isHidden = (((FileAttributes)findData.dwFileAttributes & FileAttributes.Hidden) == FileAttributes.Hidden);
                double opacity  = 1;

                if (isHidden)
                {
                    opacity = Constants.UI.DimItemOpacity;
                }

                if (itemFileExtension == ".zip" && await ZipStorageFolder.CheckDefaultZipApp(itemPath))
                {
                    return(new ZipItem(null, dateReturnFormat)
                    {
                        PrimaryItemAttribute = StorageItemTypes.Folder, // Treat zip files as folders
                        FileExtension = itemFileExtension,
                        LoadUnknownTypeGlyph = itemEmptyImgVis,
                        FileImage = null,
                        LoadFileIcon = itemThumbnailImgVis,
                        LoadFolderGlyph = itemFolderImgVis,
                        ItemName = itemName,
                        IsHiddenItem = isHidden,
                        Opacity = opacity,
                        ItemDateModifiedReal = itemModifiedDate,
                        ItemDateAccessedReal = itemLastAccessDate,
                        ItemDateCreatedReal = itemCreatedDate,
                        ItemType = itemType,
                        ItemPath = itemPath,
                        FileSize = itemSize,
                        FileSizeBytes = itemSizeBytes
                    });
                }
                else
                {
                    return(new ListedItem(null, dateReturnFormat)
                    {
                        PrimaryItemAttribute = StorageItemTypes.File,
                        FileExtension = itemFileExtension,
                        LoadUnknownTypeGlyph = itemEmptyImgVis,
                        FileImage = null,
                        LoadFileIcon = itemThumbnailImgVis,
                        LoadFolderGlyph = itemFolderImgVis,
                        ItemName = itemName,
                        IsHiddenItem = isHidden,
                        Opacity = opacity,
                        ItemDateModifiedReal = itemModifiedDate,
                        ItemDateAccessedReal = itemLastAccessDate,
                        ItemDateCreatedReal = itemCreatedDate,
                        ItemType = itemType,
                        ItemPath = itemPath,
                        FileSize = itemSize,
                        FileSizeBytes = itemSizeBytes
                    });
                }
            }
            return(null);
        }
示例#27
0
 internal static extern bool FindNextFile(
             SafeFindHandle hndFindFile,
             ref WIN32_FIND_DATA lpFindFileData);
        public static async Task <List <ListedItem> > ListEntries(
            string path,
            string returnformat,
            IntPtr hFile,
            WIN32_FIND_DATA findData,
            NamedPipeAsAppServiceConnection connection,
            CancellationToken cancellationToken,
            int countLimit,
            Func <List <ListedItem>, Task> intermediateAction
            )
        {
            var sampler     = new IntervalSampler(500);
            var tempList    = new List <ListedItem>();
            var hasNextFile = false;
            var count       = 0;

            IUserSettingsService userSettingsService = Ioc.Default.GetService <IUserSettingsService>();

            do
            {
                var isSystem = ((FileAttributes)findData.dwFileAttributes & FileAttributes.System) == FileAttributes.System;
                var isHidden = ((FileAttributes)findData.dwFileAttributes & FileAttributes.Hidden) == FileAttributes.Hidden;
                if (!isHidden || (userSettingsService.FilesAndFoldersSettingsService.AreHiddenItemsVisible && (!isSystem || !userSettingsService.FilesAndFoldersSettingsService.AreSystemItemsHidden)))
                {
                    if (((FileAttributes)findData.dwFileAttributes & FileAttributes.Directory) != FileAttributes.Directory)
                    {
                        var file = await GetFile(findData, path, returnformat, connection, cancellationToken);

                        if (file != null)
                        {
                            tempList.Add(file);
                            ++count;
                        }
                    }
                    else if (((FileAttributes)findData.dwFileAttributes & FileAttributes.Directory) == FileAttributes.Directory)
                    {
                        if (findData.cFileName != "." && findData.cFileName != "..")
                        {
                            var folder = await GetFolder(findData, path, returnformat, cancellationToken);

                            if (folder != null)
                            {
                                tempList.Add(folder);
                                ++count;
                            }
                        }
                    }
                }
                if (cancellationToken.IsCancellationRequested || count == countLimit)
                {
                    break;
                }

                hasNextFile = FindNextFile(hFile, out findData);
                if (intermediateAction != null && (count == 32 || sampler.CheckNow()))
                {
                    await intermediateAction(tempList);

                    // clear the temporary list every time we do an intermediate action
                    tempList.Clear();
                }
            } while (hasNextFile);

            FindClose(hFile);
            return(tempList);
        }
示例#29
0
 extern static bool FindNextFlashCard(IntPtr hFlashCard, ref WIN32_FIND_DATA findData);
        public static async Task <ListedItem> GetFolder(
            WIN32_FIND_DATA findData,
            string pathRoot,
            string dateReturnFormat,
            CancellationToken cancellationToken
            )
        {
            if (cancellationToken.IsCancellationRequested)
            {
                return(null);
            }

            DateTime itemModifiedDate;
            DateTime itemCreatedDate;

            try
            {
                FileTimeToSystemTime(ref findData.ftLastWriteTime, out SYSTEMTIME systemModifiedTimeOutput);
                itemModifiedDate = new DateTime(
                    systemModifiedTimeOutput.Year, systemModifiedTimeOutput.Month, systemModifiedTimeOutput.Day,
                    systemModifiedTimeOutput.Hour, systemModifiedTimeOutput.Minute, systemModifiedTimeOutput.Second, systemModifiedTimeOutput.Milliseconds,
                    DateTimeKind.Utc);

                FileTimeToSystemTime(ref findData.ftCreationTime, out SYSTEMTIME systemCreatedTimeOutput);
                itemCreatedDate = new DateTime(
                    systemCreatedTimeOutput.Year, systemCreatedTimeOutput.Month, systemCreatedTimeOutput.Day,
                    systemCreatedTimeOutput.Hour, systemCreatedTimeOutput.Minute, systemCreatedTimeOutput.Second, systemCreatedTimeOutput.Milliseconds,
                    DateTimeKind.Utc);
            }
            catch (ArgumentException)
            {
                // Invalid date means invalid findData, do not add to list
                return(null);
            }
            var    itemPath = Path.Combine(pathRoot, findData.cFileName);
            string itemName = await fileListCache.ReadFileDisplayNameFromCache(itemPath, cancellationToken);

            if (string.IsNullOrEmpty(itemName))
            {
                itemName = findData.cFileName;
            }
            bool   isHidden = (((FileAttributes)findData.dwFileAttributes & FileAttributes.Hidden) == FileAttributes.Hidden);
            double opacity  = 1;

            if (isHidden)
            {
                opacity = Constants.UI.DimItemOpacity;
            }

            return(new ListedItem(null, dateReturnFormat)
            {
                PrimaryItemAttribute = StorageItemTypes.Folder,
                ItemName = itemName,
                ItemDateModifiedReal = itemModifiedDate,
                ItemDateCreatedReal = itemCreatedDate,
                ItemType = folderTypeTextLocalized,
                LoadFolderGlyph = true,
                FileImage = null,
                IsHiddenItem = isHidden,
                Opacity = opacity,
                LoadFileIcon = false,
                ItemPath = itemPath,
                LoadUnknownTypeGlyph = false,
                FileSize = null,
                FileSizeBytes = 0,
            });
        }
示例#31
0
 private static extern IntPtr FindFirstFileExFromApp(string lpFileName,
                                                     FINDEX_INFO_LEVELS fInfoLevelId,
                                                     out WIN32_FIND_DATA lpFindFileData,
                                                     FINDEX_SEARCH_OPS fSearchOp,
                                                     IntPtr lpSearchFilter,
                                                     int dwAdditionalFlags);
示例#32
0
 internal static extern IntPtr FindFirstFile(
     [MarshalAs(UnmanagedType.LPTStr)] string lpFileName,
     out WIN32_FIND_DATA lpFindFileData);
示例#33
0
 internal static extern IntPtr FindFirstFile(String fileName, out WIN32_FIND_DATA data);
示例#34
0
 private static extern IntPtr FindFirstFile(string fileName, [In, Out] WIN32_FIND_DATA lpFindFileData);
		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);
		}
示例#36
0
 private static extern bool FindNextFile(IntPtr hFindFile, [In, Out] WIN32_FIND_DATA lpFindFileData);
示例#37
0
//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);
示例#38
0
 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);
 }
示例#39
0
文件: IO.cs 项目: sq/Fracture
        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
        }
示例#40
0
        public static async Task <List <ListedItem> > ListEntries(
            string path,
            string returnformat,
            IntPtr hFile,
            WIN32_FIND_DATA findData,
            NamedPipeAsAppServiceConnection connection,
            CancellationToken cancellationToken,
            List <string> skipItems,
            int countLimit,
            Func <List <ListedItem>, Task> intermediateAction
            )
        {
            var sampler     = new IntervalSampler(500);
            var tempList    = new List <ListedItem>();
            var hasNextFile = false;
            var count       = 0;

            do
            {
                if (((FileAttributes)findData.dwFileAttributes & FileAttributes.System) != FileAttributes.System || !App.AppSettings.AreSystemItemsHidden)
                {
                    if (((FileAttributes)findData.dwFileAttributes & FileAttributes.Hidden) != FileAttributes.Hidden || App.AppSettings.AreHiddenItemsVisible)
                    {
                        if (((FileAttributes)findData.dwFileAttributes & FileAttributes.Directory) != FileAttributes.Directory)
                        {
                            var file = await GetFile(findData, path, returnformat, connection, cancellationToken);

                            if (file != null)
                            {
                                if (skipItems?.Contains(file.ItemPath) ?? false)
                                {
                                    skipItems.Remove(file.ItemPath);
                                }
                                else
                                {
                                    tempList.Add(file);
                                }
                                ++count;
                            }
                        }
                        else if (((FileAttributes)findData.dwFileAttributes & FileAttributes.Directory) == FileAttributes.Directory)
                        {
                            if (findData.cFileName != "." && findData.cFileName != "..")
                            {
                                var folder = await GetFolder(findData, path, returnformat, cancellationToken);

                                if (folder != null)
                                {
                                    if (skipItems?.Contains(folder.ItemPath) ?? false)
                                    {
                                        skipItems.Remove(folder.ItemPath);
                                    }
                                    else
                                    {
                                        tempList.Add(folder);
                                    }
                                    ++count;
                                }
                            }
                        }
                    }
                }
                if (cancellationToken.IsCancellationRequested || count == countLimit)
                {
                    break;
                }

                hasNextFile = FindNextFile(hFile, out findData);
                if (intermediateAction != null && (count == 32 || sampler.CheckNow()))
                {
                    await intermediateAction(tempList);

                    // clear the temporary list every time we do an intermediate action
                    tempList.Clear();
                }
            } while (hasNextFile);

            FindClose(hFile);
            return(tempList);
        }
示例#41
0
 internal static extern bool FindNextFile(
             IntPtr hndFindFile, out WIN32_FIND_DATA pFindFileData);
示例#42
0
 internal static extern IntPtr FindFirstFile(string lpFileName, out WIN32_FIND_DATA lpFindFileData);
示例#43
0
 private static extern int FindNextFile(IntPtr hFindFile, out WIN32_FIND_DATA lpFindFileData);
示例#44
0
 internal static extern bool FindNextFile(IntPtr hFindFile, out WIN32_FIND_DATA lpFindFileData);
示例#45
0
 public static extern bool FindNextFile(IntPtr hFindFile, out WIN32_FIND_DATA lpFindFileData);
 private static extern IntPtr FindFirstFile(string lpFileName,
     out WIN32_FIND_DATA lpFindFileData);
示例#47
0
 public static extern bool FindNextFile(SafeFindFilesHandle hFindFile, out WIN32_FIND_DATA lpFindFileData);
示例#48
0
 private static extern IntPtr FindFirstFile([MarshalAs(UnmanagedType.VBByRefStr)] ref string lpFileName, ref WIN32_FIND_DATA lpFindFileData);
示例#49
0
 private static extern SafeFindHandle FindFirstFileExPrivate(string lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, ref WIN32_FIND_DATA lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, IntPtr lpSearchFilter, int dwAdditionalFlags);
示例#50
0
        private static string[] GetFileNames(string path, string filter /* = "*" */)
        {
            string fullPath = Path.Combine(path, filter);
            string[] textArray1 = new string[1];
            WIN32_FIND_DATA win_find_data1 = new WIN32_FIND_DATA();
            IntPtr ptr1 = FindFirstFile(ref fullPath, ref win_find_data1);
            if (ptr1.ToString() == "-1")
            {
                int num2 = Marshal.GetLastWin32Error();
                if (num2 == 2)
                {
                    return new string[0];
                }
                WinIOError(num2, path);
            }
            int num1 = 0;
            bool flag1 = true;
            do
            {
                if (((FileAttributes) 0) == (win_find_data1.dwFileAttributes & FileAttributes.Directory))
                {
                    string FileName = Encoding.ASCII.GetString(Encoding.Unicode.GetBytes(win_find_data1.cFileName)).Split(new char[] { '\0' })[0];

                    textArray1[num1] = FileName;
                    num1++;
                    if ((num1 >= textArray1.Length) && flag1)
                    {
                        string[] textArray3 = new string[((num1 * 2) - 1) + 1];
                        textArray1.CopyTo(textArray3, 0);
                        textArray1 = textArray3;
                    }
                }
            }
            while (flag1 && FindNextFile(ptr1, ref win_find_data1));
            FindClose(ptr1);
            if (num1 < textArray1.Length)
            {
                string[] textArray4 = new string[(num1 - 1) + 1];
                Array.Copy(textArray1, 0, textArray4, 0, num1);
                textArray1 = textArray4;
            }
            return textArray1;
        }
示例#51
0
 extern static IntPtr FindFirstFlashCard(ref WIN32_FIND_DATA findData);
示例#52
0
 internal static extern bool FindNextFile(SafeFindHandle hndFindFile, [In][Out][MarshalAs(UnmanagedType.LPStruct)] WIN32_FIND_DATA lpFindFileData);
示例#53
0
 protected bool _demoted; //book has no pages or BblBookDirectory renamed with no .book extension
 protected BblBook(BblLibraryRootNode root, BblLibraryNode parent, WIN32_FIND_DATA findData, BookType type) : base(root, parent, findData)
 {
     Initialize(type);
 }
示例#54
0
 internal static extern Boolean FindNextFileW(IntPtr hFindFile, out WIN32_FIND_DATA lpFindFileData);
示例#55
0
        public int FindFilesProxy(
            IntPtr rawFileName,
            IntPtr rawFillFindData, // function pointer
            ref DOKAN_FILE_INFO rawFileInfo)
        {
            String S;
            try
            {
                string file = GetFileName(rawFileName);

                ArrayList files = new ArrayList();
                int ret = operations_.FindFiles(file, files, GetFileInfo(ref rawFileInfo));

                FILL_FIND_DATA fill = (FILL_FIND_DATA)Marshal.GetDelegateForFunctionPointer(
                    rawFillFindData, typeof(FILL_FIND_DATA));

                if (ret == 0)
                {
                    IEnumerator entry = files.GetEnumerator();
                    while (entry.MoveNext())
                    {
                        FileInformation fi = (FileInformation)(entry.Current);
                        S = fi.FileName;
                        WIN32_FIND_DATA data = new WIN32_FIND_DATA();
                        //ZeroMemory(&data, sizeof(WIN32_FIND_DATAW));

                        data.dwFileAttributes = fi.Attributes;

                        data.ftCreationTime.dwHighDateTime =
                            (int)(fi.CreationTime.ToFileTime() >> 32);
                        data.ftCreationTime.dwLowDateTime =
                            (int)(fi.CreationTime.ToFileTime() & 0xffffffff);

                        data.ftLastAccessTime.dwHighDateTime =
                            (int)(fi.LastAccessTime.ToFileTime() >> 32);
                        data.ftLastAccessTime.dwLowDateTime =
                            (int)(fi.LastAccessTime.ToFileTime() & 0xffffffff);

                        data.ftLastWriteTime.dwHighDateTime =
                            (int)(fi.LastWriteTime.ToFileTime() >> 32);
                        data.ftLastWriteTime.dwLowDateTime =
                            (int)(fi.LastWriteTime.ToFileTime() & 0xffffffff);

                        data.nFileSizeLow =
                            (uint)(fi.Length & 0xffffffff);
                        data.nFileSizeHigh =
                            (uint)(fi.Length >> 32);

                        data.cFileName = fi.FileName;

                        fill(ref data, ref rawFileInfo);
                    }

                }
                return ret;

            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                return -1;
            }

        }
示例#56
0
 public static extern IntPtr FtpFindFirstFile(IntPtr hSession, string strPath, [In, Out] WIN32_FIND_DATA dirData, int nFlags, int nContext);
示例#57
0
 private static extern bool FindNextFile(IntPtr hFindFile, ref WIN32_FIND_DATA lpFindFileData);
示例#58
0
 public static extern bool InternetFindNextFile(IntPtr hFind, [In, Out] WIN32_FIND_DATA dirData);
 private static extern SafeFindHandle FindFirstFileExPrivate(string lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, ref WIN32_FIND_DATA lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, IntPtr lpSearchFilter, int dwAdditionalFlags);
示例#60
0
 internal static extern SafeFindHandle FindFirstFile(string fileName, [In][Out] WIN32_FIND_DATA data);