blog post

Rename Folder name and File name in Asp.Net.
We can rename folder and file name by using Move method which is in System.IO.Directory class.

Source Code

<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">

    protected void Page_Load(object sender, EventArgs e)

    protected void btnfolderrename_Click(object sender, EventArgs e)
        string Fromfile = HttpContext.Current.Server.MapPath("oldzip");
        string Tofile = HttpContext.Current.Server.MapPath("oldziprename");
        System.IO.Directory.Move(Fromfile, Tofile);

        Response.Write("Successfully Renamed Folder");
    protected void btnfilerename_Click(object sender, EventArgs e)
        string Fromfile = HttpContext.Current.Server.MapPath("unzipper.aspx");
        string Tofile = HttpContext.Current.Server.MapPath("un-zipper.aspx");
        System.IO.Directory.Move(Fromfile, Tofile);
        Response.Write("Successfully Renamed File");

<html xmlns="">
<head runat="server">
<title>Rename File and Folder</title>
<form id="form1" runat="server">

<asp:Button ID="btnfolderrename" runat="server" Text="Rename Folder" OnClick="btnfolderrename_Click" /><asp:Button ID="btnfilerename" runat="server" Text="Rename File" OnClick="btnfilerename_Click" />&nbsp;&nbsp;&nbsp;

  • Share This Story

Pleas give your valuable comments to improve the contents.

about author

Atul kumar shukla

I'm Atul Kumar Shukla, working as a web developer.
Welcome to my Blog. This is my personal blog where i post my own questions and answers , articles about ASP.Net., SQL Server, HTML, CSS, Jquery and many more..

Visit Profile

Leave a comment


Get More Stuff
Subscribing to the TheOneblogs newsletter and get intersting stuff and updates to your email inbox.
Your Email


Style Switcher

Change Color

×! We use cookies to improve your user experience. More information