Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

move file from one folder to another c#

 //take all files of main folder to folder model_RCCMrecTransfered 
            string rootFolderPath = @"F:/model_RCCMREC/";
            string destinationPath = @"F:/model_RCCMrecTransfered/";
            string filesToDelete = @"*_DONE.wav";   // Only delete WAV files ending by "_DONE" in their filenames
            string[] fileList = System.IO.Directory.GetFiles(rootFolderPath, filesToDelete);
            foreach (string file in fileList)
            {
                string fileToMove = rootFolderPath + file;
                string moveTo = destinationPath + file;
                //moving file
                File.Move(fileToMove, moveTo);
Comment

move files from one directory to another using c#

using System.IO;

string rootDirectory = @"C:UsersUSERFolder1";
string destinationDirectory = @"C:UsersUSERFolder2";

string[] Files = Directory.GetFiles(rootDirectory);

foreach (string file in Files) {
	File.Move(file, $"{destinationDirectory}{Path.GetFileName(file)}");
}
Comment

c# move files from one folder to another

        /// <summary>
        /// Move files and Directory
        /// </summary>
        /// <param name="fromPath"></param>
        /// <param name="toPath"></param>
        /// <param name="addDateTimeSubFolder"></param>
        Using System.IO;
        public static void Move(string fromPath, string toPath, bool addDateTimeSubFolder)
        {
            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 (addDateTimeSubFolder)
            {
                var subFolder = DateTime.Now.ToString("YYYYMMDD");
                Directory.Move(fromPath, toPath + @"" + subFolder);
            }
            else
            {
                Directory.Move(fromPath, toPath);
            }

        }
Comment

move file from one folder to another c#

 //take all files of main folder to folder model_RCCMrecTransfered 
            string rootFolderPath = @"F:/model_RCCMREC/";
            string destinationPath = @"F:/model_RCCMrecTransfered/";
            string filesToDelete = @"*_DONE.wav";   // Only delete WAV files ending by "_DONE" in their filenames
            string[] fileList = System.IO.Directory.GetFiles(rootFolderPath, filesToDelete);
            foreach (string file in fileList)
            {
                string fileToMove = rootFolderPath + file;
                string moveTo = destinationPath + file;
                //moving file
                File.Move(fileToMove, moveTo);
Comment

move files from one directory to another using c#

using System.IO;

string rootDirectory = @"C:UsersUSERFolder1";
string destinationDirectory = @"C:UsersUSERFolder2";

string[] Files = Directory.GetFiles(rootDirectory);

foreach (string file in Files) {
	File.Move(file, $"{destinationDirectory}{Path.GetFileName(file)}");
}
Comment

c# move files from one folder to another

        /// <summary>
        /// Move files and Directory
        /// </summary>
        /// <param name="fromPath"></param>
        /// <param name="toPath"></param>
        /// <param name="addDateTimeSubFolder"></param>
        Using System.IO;
        public static void Move(string fromPath, string toPath, bool addDateTimeSubFolder)
        {
            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 (addDateTimeSubFolder)
            {
                var subFolder = DateTime.Now.ToString("YYYYMMDD");
                Directory.Move(fromPath, toPath + @"" + subFolder);
            }
            else
            {
                Directory.Move(fromPath, toPath);
            }

        }
Comment

PREVIOUS NEXT
Code Example
Csharp :: hash table in c# 
Csharp :: convert string to list int c# 
Csharp :: c# create list with range 
Csharp :: c# is in array 
Csharp :: int to bool c# 
Csharp :: c# new dictionary linq 
Csharp :: c# update control from another thread 
Csharp :: list clone - C# 
Csharp :: order by length descending C# 
Csharp :: change dot net core web api routing 
Csharp :: how to move object with keyboard in unity 3D 
Csharp :: asp.net core get root url in view 
Csharp :: unity button onclick 
Csharp :: How to take input on float in c# 
Csharp :: find genre of song 
Csharp :: c# get country code 
Csharp :: c# cancellationtoken example 
Csharp :: Pass Querystring in C# httpclient 
Csharp :: roman to 
Csharp :: windows form textbox password 
Csharp :: scene switch unity 
Csharp :: datatable linq where clause c# 
Csharp :: parent unity 
Csharp :: or c# 
Csharp :: how to make an ui to follow gameobject 
Csharp :: how to get keyboard input in unity 
Csharp :: c# use api rest 
Csharp :: C# clear console input buffer 
Csharp :: how to validate if date is a weekday or weekend c# 
Csharp :: c# picturebox transparente 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =