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

c# move files from one folder to another

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 :: scenemanager.loadscene 
Csharp :: c# remove character from string at index 
Csharp :: c# list slice 
Csharp :: get folder path winforms 
Csharp :: asp.net file detect mime type 
Csharp :: list to list<selectlistitem c# 
Csharp :: visual studio console clear 
Csharp :: c# messagebox result 
Csharp :: char contains c# 
Csharp :: Local to global position unity 
Csharp :: 2 rotation unity 
Csharp :: flip a character in unity 
Csharp :: optimistic update 
Csharp :: add variable to the beginning of a list c# 
Csharp :: c# clamp 
Csharp :: ajax asp.net core 
Csharp :: merge xml files into one c# 
Csharp :: unity call function from another script 
Csharp :: c# swtich 
Csharp :: joins List of strings 
Csharp :: create new .net project 
Csharp :: wpf color picker 
Csharp :: c# remove first three characters from string 
Csharp :: unity 3d movement script 
Csharp :: wpf resource dictionary 
Csharp :: C# datareadeer return null 
Csharp :: trim c# 
Csharp :: increase value in dictionary against a key in c# 
Csharp :: c# how to check for internet connectivity 
Csharp :: how to find current country c# 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =