Check folder and Delete All Files from Existing Folder in C#

Dynamically check the Particular name Folder exist or not, it not exits create folder dynamically.


if (!Directory.Exists(FolderName))
        {

            Directory.CreateDirectory(FolderName);
        }

        if (Directory.Exists(FolderName))
        {
            string[] filePaths = Directory.GetFiles(FolderName);
            foreach (string filePath in filePaths)
                File.Delete(filePath);
            //Directory.Delete(FolderName);           
        }

Comments

Popular posts from this blog

SQL Query :- Create Tables,Primary key,Foreign key,Merge Statment

AngularJS