C \ # 파일 흐름 작업 의 삭제, 복사, 이동 여러 파일

1949 단어 StringC#File
 string[] format = { "*.jpg", "*.doc", "*.exe", "*.pdf", "*.xls" };

C#           、  、      

       /// <summary>
        ///            
        /// </summary>
        /// <param name="oldpngPath">       </param>
        /// <param name="newpngPath">       </param>
        /// <param name="geshi">          :*.png、*.xml</param>
        public void deleteAll(string delpath, string format )
        {
            string[] files = Directory.GetFiles(delpath, format[0]);
            foreach (string file in files)
            {
                File.Delete(file);
            }
        }
        /// <summary>
        ///            
        /// </summary>
        /// <param name="oldpngPath">       </param>
        /// <param name="newpngPath">       </param>
        /// <param name="geshi">          :*.png、*.xml</param>
        public void copyALl(string oldpngPath, string newpngPath, string format )
        {
            string[] files = Directory.GetFiles(oldpngPath, format[0]);
            foreach (string file in files)
            {
                string otherFile = Path.Combine(oldpngPath, Path.GetFileName(file));
                File.Copy(file, newpngPath + "\\" + Path.GetFileName(file));
            }
        }
       /// <summary>
        ///            
        /// </summary>
        /// <param name="olderpath">        </param>
        /// <param name="topath">   </param>
        public void moveAll(string olderpath, string topath)
        {
            string[] files = Directory.GetFiles(delpath, format[0]);
            foreach (string file in files)
            {
                File.Move(file, topath); //    
            }
        }

좋은 웹페이지 즐겨찾기