Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# move directory

        /// <summary>
        /// Move Directory and files
        /// </summary>
        /// <param name="fromPath"></param>
        /// <param name="toPath"></param>
		Using System.IO;
        public static void Move(string fromPath, string toPath)
        {
            if (string.IsNullOrEmpty(fromPath))
            {
                throw new ArgumentException($"'{nameof(fromPath)}' cannot be null or empty", nameof(fromPath));
            }

            if (string.IsNullOrEmpty(toPath))
            {
                throw new ArgumentException($"'{nameof(toPath)}' cannot be null or empty", nameof(toPath));
            }

            if (!Directory.Exists(fromPath))
            {
                throw new ArgumentException($"'{nameof(fromPath)}' Directory does not exist", nameof(fromPath));
            }
            else
            {
                Directory.Move(fromPath, toPath);
            }
        }
 
PREVIOUS NEXT
Tagged: #move #directory
ADD COMMENT
Topic
Name
9+8 =