24 Mart 2012 Cumartesi

C# - Klasör içindeki tüm dosyaları kopyalama

       /// <summary>
       /// Klasör İçindeki Dosyaları Kopyalamaktadır.
       /// </summary>
       /// <param name="sourcePatch">Kaynak yol</param>
       /// <param name="targetPatch">Hedef</param>
       /// <returns></returns>
        public static bool FolderCopy(string sourcePatch, string targetPatch)
        {
            if (String.IsNullOrEmpty(sourcePatch) || string.IsNullOrEmpty(targetPatch))
            {
                return false;
            }
            try
            {
                string[] folderInFile = Directory.GetFiles(sourcePatch);
                string[] fileName;
                for (int i = 0; i < folderInFile.Length; i++)
                {
                    fileName = folderInFile[i].Split('\\');
                    File.Copy(folderInFile[i], String.Format("{0}\\{1}", targetPatch, fileName[fileName.Length - 1]));
                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        } 

0 yorum:

Yorum Gönder

Yorumlarınız için Teşekkür Ederiz...