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");
    }


</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Rename File and Folder</title>
</head>
<body>
<form id="form1" runat="server">
<div>

<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;
</div>
</form>
</body>
</html>

  • 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

Name
E-mail
Url
Message

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