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 folder 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 :: c# loop 
Csharp :: unity get a position inside sphere 
Csharp :: convert object to xml c# example code 
Csharp :: unity iterate all child objects 
Csharp :: c# get bits from float 
Csharp :: checkbox value unchecked after return view model 
Csharp :: c# writteline 
Csharp :: how to parse a string to an integer c# 
Csharp :: how to check if control key is pressed c# 
Csharp :: delete all dir content c# 
Csharp :: get enum by index c# 
Csharp :: newtonsoft json conditionally ignore property 
Csharp :: c# get all class properties 
Csharp :: unity remove parent 
Csharp :: c# @ before string 
Csharp :: get distinct from datatable c# 
Csharp :: set object to random color unity 
Csharp :: unity making a coroutine wait until another coroutine is done 
Csharp :: get normal from 3 points 
Csharp :: unity destroy object invisible 
Csharp :: excute bash and other linux scripts from c# 
Csharp :: enable fullscreen unity code 
Csharp :: .net mvc c# alert to client browswer window 
Csharp :: loop over enum values 
Csharp :: entity framework update child records 
Csharp :: dropdown wpf 
Csharp :: placeholder syntax c# 
Csharp :: base64 decode how used in c# 
Csharp :: csharp 
Csharp :: how to make a global string c# 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =