zoukankan      html  css  js  c++  java
  • 移动文件

    /// <summary>
            /// Moves an existing file or directory, including its children, with various move options.
            /// The MoveFileWithProgress function is equivalent to the MoveFileEx function, except that MoveFileWithProgress allows you to provide a callback function that receives progress notifications.
            /// To perform this operation as a transacted operation, use the MoveFileTransacted function.
            /// </summary>
            /// <param name="lpExistingFileName">The current name of the file or directory on the local computer.
            /// If dwFlags specifies MOVEFILE_DELAY_UNTIL_REBOOT, the file cannot exist on a remote share, because delayed operations are performed before the network is available.
            /// In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\?" to the path. For more information, see Naming a File</param>
            /// <param name="lpNewFileName">The new name of the file or directory on the local computer.
            /// When moving a file, the destination can be on a different file system or volume. If the destination is on another drive, you must set the MOVEFILE_COPY_ALLOWED flag in dwFlags.
            /// When moving a directory, the destination must be on the same drive.
            /// If dwFlags specifies MOVEFILE_DELAY_UNTIL_REBOOT and lpNewFileName is NULL, MoveFileEx registers the lpExistingFileName file to be deleted when the system restarts. If lpExistingFileName refers to a directory, the system removes the directory at restart only if the directory is empty.</param>
            /// <param name="dwFlags"></param>
            /// <returns>If the function succeeds, the return value is nonzero.</returns>
            [return: MarshalAs(UnmanagedType.Bool)]
            [DllImport("kernel32", CharSet = CharSet.Auto, SetLastError = true)]
            private static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFile dwFlags);
    
            public enum MoveFile : uint
            {
                /// <summary>
                /// If the file is to be moved to a different volume, the function simulates the move by using the CopyFile and DeleteFile functions.
                /// If the file is successfully copied to a different volume and the original file is unable to be deleted, the function succeeds leaving the source file intact.
                /// This value cannot be used with MOVEFILE_DELAY_UNTIL_REBOOT.
                /// </summary>
                MOVEFILE_COPY_ALLOWED = 0x2,
                /// <summary>
                /// Reserved for future use.
                /// </summary>
                MOVEFILE_CREATE_HARDLINK = 0x10,
                /// <summary>
                /// The system does not move the file until the operating system is restarted. The system moves the file immediately after AUTOCHK is executed, but before creating any paging files. Consequently, this parameter enables the function to delete paging files from previous startups.
                /// This value can be used only if the process is in the context of a user who belongs to the administrators group or the LocalSystem account.
                /// This value cannot be used with MOVEFILE_COPY_ALLOWED.
                /// Windows Server 2003 and Windows XP:  For information about special situations where this functionality can fail, and a suggested workaround solution, see Files are not exchanged when Windows Server 2003 restarts if you use the MoveFileEx function to schedule a replacement for some files in the Help and Support Knowledge Base.
                /// </summary>
                MOVEFILE_DELAY_UNTIL_REBOOT = 0x4,
                /// <summary>
                /// The function fails if the source file is a link source, but the file cannot be tracked after the move. This situation can occur if the destination is a volume formatted with the FAT file system.
                /// </summary>
                MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20,
                /// <summary>
                /// If a file named lpNewFileName exists, the function replaces its contents with the contents of the lpExistingFileName file, provided that security requirements regarding access control lists (ACLs) are met. For more information, see the Remarks section of this topic.
                /// This value cannot be used if lpNewFileName or lpExistingFileName names a directory.
                /// </summary>
                MOVEFILE_REPLACE_EXISTING = 0x1,
                /// <summary>
                /// The function does not return until the file is actually moved on the disk.
                /// Setting this value guarantees that a move performed as a copy and delete operation is flushed to disk before the function returns. The flush occurs at the end of the copy operation.
                /// This value has no effect if MOVEFILE_DELAY_UNTIL_REBOOT is set.
                /// </summary>
                MOVEFILE_WRITE_THROUGH = 0x8
    
            }
  • 相关阅读:
    UVA 1025 A Spy in the Metro DP水题
    ZOJ 3814 Sawtooth Puzzle BFS
    ZOJ 3816 Generalized Palindromic Number
    UVA 10859 Placing Lampposts 树形DP
    UVA 11825 Hackers' Crackdown 状压DP
    POJ 2887 Big String 线段树 离线处理
    POJ 1635 Subway tree systems Hash法判断有根树是否同构
    BZOJ 3110 k大数查询 & 树套树
    sdoi 2009 & 状态压缩
    来自于2016.2.24的flag
  • 原文地址:https://www.cnblogs.com/wjshan0808/p/4241385.html
Copyright © 2011-2022 走看看