Thursday, 15 November 2012

Clean File and Folders Using C#

Clean File and Folders Using C#


Clean File:

        public static bool CleanupFile(string path)

        {

            try

            {

                if (File.Exists(path))

                {

                    File.SetAttributes(path, FileAttributes.Normal);

                    File.Delete(path);

                }

                return true;

             }

            catch

            {

               return false;

            }

        }


Clean Folder:


        public static bool CleanupFolder(string folder)

        {

            try

            {

                if (Directory.Exists(folder))

                    Directory.Delete(folder, true);

                return true;

            }

            catch

            {

                return false;

            }

        }

No comments:

Post a Comment

Thank You for Your Comments. We will get back to you soon.

back to top