locked
Renaming a folder RRS feed

  • Question

  • User-735851359 posted

    Hello,

    How can I rename an existing folder?

    There are the methods Create, Delete, Move but no Rename?

    Saturday, April 18, 2015 8:19 AM

Answers

  • User-138061656 posted

    you can do this with Move method.Appy Move method to folder with new folder name for same location.

    Directory.Move(@"c:\folderName", @"c:\newFolderName");

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, April 18, 2015 6:22 PM
  • User-1716253493 posted
            string spath = Server.MapPath("~/test");
            string subfoldername = "abc";
            string newsubfoldername = "xyz";
            Directory.Move(Path.Combine(spath,subfoldername),Path.Combine(spath,newsubfoldername));

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 20, 2015 2:12 AM

All replies

  • User-138061656 posted

    you can do this with Move method.Appy Move method to folder with new folder name for same location.

    Directory.Move(@"c:\folderName", @"c:\newFolderName");

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, April 18, 2015 6:22 PM
  • User-1716253493 posted
            string spath = Server.MapPath("~/test");
            string subfoldername = "abc";
            string newsubfoldername = "xyz";
            Directory.Move(Path.Combine(spath,subfoldername),Path.Combine(spath,newsubfoldername));

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 20, 2015 2:12 AM