コード例 #1
0
ファイル: FileHelper.cs プロジェクト: Ytrog/RssBandit
        /// <summary>
        /// Move a file from a folder to a new one.
        /// </summary>
        /// <param name="existingFileName">The original file name.</param>
        /// <param name="newFileName">The new file name.</param>
        /// <param name="flags">Flags about how to move the files.</param>
        /// <returns>indicates whether the file was moved.</returns>
        public static bool MoveFile(string existingFileName, string newFileName, MoveFileFlag flags)
        {
            int retries = 10;

            while (retries > 0)
            {
                try {
                    return(NativeMethods.MoveFileEx(existingFileName, newFileName, flags));
                }
                catch (Exception) {
                    retries--;

                    if (retries <= 0)
                    {
                        throw;                          // giving up and report error
                    }
                    // yield control to other threads so that we get a little
                    // wait before we retry.
                    Thread.Sleep(msecsBetweenRetries);
                    continue;
                }
            }            //while

            return(false);
        }
コード例 #2
0
ファイル: FileHelper.cs プロジェクト: Ytrog/RssBandit
 internal static extern bool MoveFileEx(
     string lpExistingFileName,
     string lpNewFileName,
     MoveFileFlag dwFlags);
コード例 #3
0
 public static bool MoveFile(string existingFileName, string newFileName, MoveFileFlag flags)
 {
     return(MoveFileEx(existingFileName, newFileName, (int)flags));
 }