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

PREVIOUS NEXT
Code Example
Csharp :: move files from one folder to another using c# 
Csharp :: vscode not showing errors c# 
Csharp :: c# datetime format ymd 
Csharp :: c# dictionary to json 
Csharp :: how to add to a list c# 
Csharp :: capitalize first letter c# 
Csharp :: unity post processing ui 2d 
Csharp :: ngrok for https 
Csharp :: c# contains 
Csharp :: unity vs unreal for beginners 
Csharp :: editorfor date format mvc 
Csharp :: get attribute value of xml element c# 
Csharp :: unity play sound effect 
Csharp :: badlion 
Csharp :: average c# 
Csharp :: c# add to array 
Csharp :: regex c# 
Csharp :: how to work with ascii in c# 
Csharp :: roman to number 
Csharp :: c# performance timer 
Csharp :: c# convert datetime to unix timestamp 
Csharp :: c# datagridview header color 
Csharp :: c# get foreground window 
Csharp :: timespan to integer c# 
Csharp :: c# get total milliseconds from datetime 
Csharp :: set rotation unity 
Csharp :: unity create 3d object in script 
Csharp :: IHttpContextAccessor 
Csharp :: convert-integer-to-binary-in-c-sharp 
Csharp :: c# binary search 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =