Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
//i have folders GallaryFolder->AlbumFolder->ImagesFolder->Images Files
//and have used this code for rename the folder


C#
DirectoryInfo imageFolder = new DirectoryInfo(Server.MapPath("~/Gallary/") + str + "/Images/");
            string Imgpath = "~/Gallary/" + str + "/Images/";

            bool isImg = System.IO.Directory.Exists(Server.MapPath(Imgpath));
            if (isImg==true)
            {
                DirectoryInfo newimageFolder = new DirectoryInfo(Server.MapPath("~/Gallary/") + txtname.Text + "/Images/{0}");
                string newImgpath = "~/Gallary/" + txtname.Text + "/Images/";
                bool isnewImg = System.IO.Directory.Exists(Server.MapPath(newImgpath));
                if (!isnewImg)
                {                    
                    newimageFolder.Create();
                    Directory.Move(Imgpath, newImgpath);
                    xmldoc.Save(Server.MapPath("~/" + "XML/album.xml"));
                }                         
            }  


//but only GallaryFolder->AlbumFolder->ImagesFolder it is getting copied images files are not getting copied.
can you please tell me where i am going wrong.
Posted
Updated 12-Feb-14 1:29am
v2
Comments
Richard MacCutchan 12-Feb-14 8:38am    
You seem to be using different, and confusing, paths in the above. You test whether the path "~/Gallary/") + txtname.Text + "/Images" exists, and if not, you create a new folder with the name "~/Gallary/") + txtname.Text + "/Images/{0}"; what are the characters {0} supposed to be there for? You then rename the directory from the existing name to the new name, and save an xml file in the ~/XML directory.

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900