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. Other Discussions
  3. The Weird and The Wonderful
  4. Superman if-clause

Superman if-clause

Scheduled Pinned Locked Moved The Weird and The Wonderful
question
12 Posts 11 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.
  • F freakyit

    just looked into the code of an project made from a workmate. may be he thought superman would fly in and delete the folder between the two if-clauses xD

    if (System.IO.Directory.Exists(dest))
    {
    if (!System.IO.Directory.Exists(dest))
    {
    System.IO.Directory.CreateDirectory(dest);
    }

    fullDest = dest + fileInfo.Name; // what is if Directory seperator is missing? xD
    

    }

    K Offline
    K Offline
    Keith Barrow
    wrote on last edited by
    #2

    Epic fail. Written at 4am by any chance :-) ?

    Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter. Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.

    1 Reply Last reply
    0
    • F freakyit

      just looked into the code of an project made from a workmate. may be he thought superman would fly in and delete the folder between the two if-clauses xD

      if (System.IO.Directory.Exists(dest))
      {
      if (!System.IO.Directory.Exists(dest))
      {
      System.IO.Directory.CreateDirectory(dest);
      }

      fullDest = dest + fileInfo.Name; // what is if Directory seperator is missing? xD
      

      }

      K Offline
      K Offline
      Kevin Drzycimski
      wrote on last edited by
      #3

      freakyit wrote:

      may be he thought superman would fly in and delete the folder between the two if-clauses

      this could actually happen in a multi threaded environment but then he would fly by again after the creation and delete it again =/

      1 Reply Last reply
      0
      • F freakyit

        just looked into the code of an project made from a workmate. may be he thought superman would fly in and delete the folder between the two if-clauses xD

        if (System.IO.Directory.Exists(dest))
        {
        if (!System.IO.Directory.Exists(dest))
        {
        System.IO.Directory.CreateDirectory(dest);
        }

        fullDest = dest + fileInfo.Name; // what is if Directory seperator is missing? xD
        

        }

        O Offline
        O Offline
        oggenok64
        wrote on last edited by
        #4

        Looks like a classic example of code that originally did more than this. After the "more" was moved to somewhere else, this snippet was what was left behind. I've seen many examples and they always make the original programmer look really stupid. Have to admit - I've even done it myself :-)

        1 Reply Last reply
        0
        • F freakyit

          just looked into the code of an project made from a workmate. may be he thought superman would fly in and delete the folder between the two if-clauses xD

          if (System.IO.Directory.Exists(dest))
          {
          if (!System.IO.Directory.Exists(dest))
          {
          System.IO.Directory.CreateDirectory(dest);
          }

          fullDest = dest + fileInfo.Name; // what is if Directory seperator is missing? xD
          

          }

          R Offline
          R Offline
          Rob Grainger
          wrote on last edited by
          #5

          Shurely,

          string IsSuperman() {
          if (IsItABird())
          return "Bird";
          else if (IsItAPlane())
          return "Plane";
          else
          return "Superman";
          }

          (Sorry - its a bad job, but someone's gotta do it.)

          G 1 Reply Last reply
          0
          • R Rob Grainger

            Shurely,

            string IsSuperman() {
            if (IsItABird())
            return "Bird";
            else if (IsItAPlane())
            return "Plane";
            else
            return "Superman";
            }

            (Sorry - its a bad job, but someone's gotta do it.)

            G Offline
            G Offline
            GibbleCH
            wrote on last edited by
            #6

            Where's "Super Grover"?

            1 Reply Last reply
            0
            • F freakyit

              just looked into the code of an project made from a workmate. may be he thought superman would fly in and delete the folder between the two if-clauses xD

              if (System.IO.Directory.Exists(dest))
              {
              if (!System.IO.Directory.Exists(dest))
              {
              System.IO.Directory.CreateDirectory(dest);
              }

              fullDest = dest + fileInfo.Name; // what is if Directory seperator is missing? xD
              

              }

              D Offline
              D Offline
              DanWalker
              wrote on last edited by
              #7

              Did you just not READ the comment? He's concerned that the path separator is missing from the end of the dest variable. A not unreasonable concern. Your coworker knows about the System.IO namespace.. but apparently not the Path object. Path.Combine() is what he's in need of.

              R 1 Reply Last reply
              0
              • F freakyit

                just looked into the code of an project made from a workmate. may be he thought superman would fly in and delete the folder between the two if-clauses xD

                if (System.IO.Directory.Exists(dest))
                {
                if (!System.IO.Directory.Exists(dest))
                {
                System.IO.Directory.CreateDirectory(dest);
                }

                fullDest = dest + fileInfo.Name; // what is if Directory seperator is missing? xD
                

                }

                A Offline
                A Offline
                Abhinav S
                wrote on last edited by
                #8

                This leads me to once again point out how important that cup of coffee is before commencing to write any code. :)

                The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.

                F 1 Reply Last reply
                0
                • A Abhinav S

                  This leads me to once again point out how important that cup of coffee is before commencing to write any code. :)

                  The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.

                  F Offline
                  F Offline
                  freakyit
                  wrote on last edited by
                  #9

                  commited :)

                  1 Reply Last reply
                  0
                  • D DanWalker

                    Did you just not READ the comment? He's concerned that the path separator is missing from the end of the dest variable. A not unreasonable concern. Your coworker knows about the System.IO namespace.. but apparently not the Path object. Path.Combine() is what he's in need of.

                    R Offline
                    R Offline
                    RugbyLeague
                    wrote on last edited by
                    #10

                    Path.Combine doesn't always work as one would wish

                    1 Reply Last reply
                    0
                    • F freakyit

                      just looked into the code of an project made from a workmate. may be he thought superman would fly in and delete the folder between the two if-clauses xD

                      if (System.IO.Directory.Exists(dest))
                      {
                      if (!System.IO.Directory.Exists(dest))
                      {
                      System.IO.Directory.CreateDirectory(dest);
                      }

                      fullDest = dest + fileInfo.Name; // what is if Directory seperator is missing? xD
                      

                      }

                      L Offline
                      L Offline
                      leppie
                      wrote on last edited by
                      #11

                      Both the exists checks are unneeded. A manual would be more appropriate. The FMSDN says: If the directory already exists, this method does nothing.

                      xacc.ide
                      IronScheme - 1.0 RC 1 - out now!
                      ((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth Edition

                      1 Reply Last reply
                      0
                      • F freakyit

                        just looked into the code of an project made from a workmate. may be he thought superman would fly in and delete the folder between the two if-clauses xD

                        if (System.IO.Directory.Exists(dest))
                        {
                        if (!System.IO.Directory.Exists(dest))
                        {
                        System.IO.Directory.CreateDirectory(dest);
                        }

                        fullDest = dest + fileInfo.Name; // what is if Directory seperator is missing? xD
                        

                        }

                        K Offline
                        K Offline
                        Kommrad Homer
                        wrote on last edited by
                        #12

                        we cant know! we cant judge.its windows afterall :D

                        d'Oh!

                        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