Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Directory Rename

Directory Rename

Scheduled Pinned Locked Moved C#
csharphelptutorial
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rakesh_nits
    wrote on last edited by
    #1

    Hi All, I have a very simple problem .I want to rename a directory using C#.But I am not changing the location of directory neither its name(letters) just the case(from upper to lower or vice a versa).now if i use Directory.Move or MoveTo method of directoryinfo class i get the exception that source and destination must be different.one way around this problem is that i should use move or moveto twice first moving this directory to somewhere else then moving it again with the name having different case.but i don't want to do that.Can somebody tell me how to do this.Thanks in Advance. Rakesh

    S 1 Reply Last reply
    0
    • R rakesh_nits

      Hi All, I have a very simple problem .I want to rename a directory using C#.But I am not changing the location of directory neither its name(letters) just the case(from upper to lower or vice a versa).now if i use Directory.Move or MoveTo method of directoryinfo class i get the exception that source and destination must be different.one way around this problem is that i should use move or moveto twice first moving this directory to somewhere else then moving it again with the name having different case.but i don't want to do that.Can somebody tell me how to do this.Thanks in Advance. Rakesh

      S Offline
      S Offline
      shafqaat
      wrote on last edited by
      #2

      First Create new directory for destination. Than copy or move source.

      R 1 Reply Last reply
      0
      • S shafqaat

        First Create new directory for destination. Than copy or move source.

        R Offline
        R Offline
        rakesh_nits
        wrote on last edited by
        #3

        Hi shafqaat, You didn't get it.if my directory is C:\My Documents\pictures i want to Change it to C:\My Documents\PIctures .I mean i just want to change the case of some letters in the name of the directory.not its location.any suggestions.Thanks in Advance. Rakesh

        C S 2 Replies Last reply
        0
        • R rakesh_nits

          Hi shafqaat, You didn't get it.if my directory is C:\My Documents\pictures i want to Change it to C:\My Documents\PIctures .I mean i just want to change the case of some letters in the name of the directory.not its location.any suggestions.Thanks in Advance. Rakesh

          C Offline
          C Offline
          Curtis Schlak
          wrote on last edited by
          #4

          Since Windows has a case-insensitive view of the file system, "C:\My Documents\Pictures" and "C:\My Documents\pictures" is the same. You cannot change the case only. Try renaming it to "C:\My Documents\pictures.tmp" and then back to "C:\My Documents\Pictures". "we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty

          R 1 Reply Last reply
          0
          • R rakesh_nits

            Hi shafqaat, You didn't get it.if my directory is C:\My Documents\pictures i want to Change it to C:\My Documents\PIctures .I mean i just want to change the case of some letters in the name of the directory.not its location.any suggestions.Thanks in Advance. Rakesh

            S Offline
            S Offline
            shafqaat
            wrote on last edited by
            #5

            Create a Directory Pictures(not on the same location of pictures).And move Contents of pictures to Pictures. Delete pictures Move Pictures to the location of pictures. For optimization the best way is to create Pictures on same drive (the one have pictures) in any other dummy directory and than delete pictures and than move Pictures to location of pictures. Like c:\\MyDummy\\Pictures

            1 Reply Last reply
            0
            • C Curtis Schlak

              Since Windows has a case-insensitive view of the file system, "C:\My Documents\Pictures" and "C:\My Documents\pictures" is the same. You cannot change the case only. Try renaming it to "C:\My Documents\pictures.tmp" and then back to "C:\My Documents\Pictures". "we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty

              R Offline
              R Offline
              rakesh_nits
              wrote on last edited by
              #6

              Thanks for your reply.I know windows is case insensitive.In files case the case can be changed using MoveTo method of filesysteminfo class.it changes the case .is there any equivalent for directory may be any api or anything.thanks again. Rakesh

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups