ReName Folder - CSharp File IO

CSharp examples for File IO:Directory

Description

ReName Folder

Demo Code


using System.Threading;
using System.Windows.Forms;
using System.Diagnostics;
using System.Xml;
using System.IO.Compression;
using System.IO;/*from  www.  j  av  a  2s .c  om*/
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.UI;
using System.Web;
using System.Text;
using System.Collections.Generic;
using System.Configuration;
using System;

public class Main{
        public static bool ReNameFloder(string OldFloderName, string NewFloderName)
        {
            try
            {
                if (Directory.Exists(HttpContext.Current.Server.MapPath("//") + OldFloderName))
                {
                    Directory.Move(HttpContext.Current.Server.MapPath("//") + OldFloderName, HttpContext.Current.Server.MapPath("//") + NewFloderName);
                }
                return true;
            }
            catch
            {
                return false;
            }
        }
}

Related Tutorials