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. If File exist

If File exist

Scheduled Pinned Locked Moved The Weird and The Wonderful
comsysadminhelpquestionworkspace
7 Posts 5 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.
  • Y Offline
    Y Offline
    Yusuf
    wrote on last edited by
    #1

    I am supporting a legacy asp/vb COM app X| with little or no documentation I upgraded a server with some bug fixes, as usual something did not work. roll sleeve up and let us dig for clue. The COM app logs extensively to the event log, but there is no single entry. I checked all settting and there is no configuration issues. I gave up and started to look into the code why it is not logging and I came across

    If FileExists("C:\WriteLog.Txt") Then
    Dim objData As New Data
    Dim icnt As Integer
    icnt = 0
    Do While Not FileExists(uploadPath) Or FileLen(uploadPath) = 0
    If Not FileExists(uploadPath) Then
    Call objData.WriteToNTLog("No file", 2)
    Else
    Call objData.WriteToNTLog("Length 0", 2)
    End If
    Loop
    ' note that path to exe is quoted to allow spaces in path spec
    Call objData.WriteToNTLog("""" & GetImageMagickPath() & "convert"" """
    & uploadPath & """" & opStr & " """ & thumbPath & """", 4)
    End If

    WHY:confused: check C:\WriteLog.txt before wrting to the event log. I am sure the app use to log to that file then they changed it to log to the eventlog. But why leave the file check there? The app has a configuration file and why not set logging flag in the app configuration file. :confused: X| :mad:

    Yusuf

    T O D 3 Replies Last reply
    0
    • Y Yusuf

      I am supporting a legacy asp/vb COM app X| with little or no documentation I upgraded a server with some bug fixes, as usual something did not work. roll sleeve up and let us dig for clue. The COM app logs extensively to the event log, but there is no single entry. I checked all settting and there is no configuration issues. I gave up and started to look into the code why it is not logging and I came across

      If FileExists("C:\WriteLog.Txt") Then
      Dim objData As New Data
      Dim icnt As Integer
      icnt = 0
      Do While Not FileExists(uploadPath) Or FileLen(uploadPath) = 0
      If Not FileExists(uploadPath) Then
      Call objData.WriteToNTLog("No file", 2)
      Else
      Call objData.WriteToNTLog("Length 0", 2)
      End If
      Loop
      ' note that path to exe is quoted to allow spaces in path spec
      Call objData.WriteToNTLog("""" & GetImageMagickPath() & "convert"" """
      & uploadPath & """" & opStr & " """ & thumbPath & """", 4)
      End If

      WHY:confused: check C:\WriteLog.txt before wrting to the event log. I am sure the app use to log to that file then they changed it to log to the eventlog. But why leave the file check there? The app has a configuration file and why not set logging flag in the app configuration file. :confused: X| :mad:

      Yusuf

      T Offline
      T Offline
      Tony Pottier
      wrote on last edited by
      #2

      Why? Wouldn't be fun if everything was working perfectly.

      1 Reply Last reply
      0
      • Y Yusuf

        I am supporting a legacy asp/vb COM app X| with little or no documentation I upgraded a server with some bug fixes, as usual something did not work. roll sleeve up and let us dig for clue. The COM app logs extensively to the event log, but there is no single entry. I checked all settting and there is no configuration issues. I gave up and started to look into the code why it is not logging and I came across

        If FileExists("C:\WriteLog.Txt") Then
        Dim objData As New Data
        Dim icnt As Integer
        icnt = 0
        Do While Not FileExists(uploadPath) Or FileLen(uploadPath) = 0
        If Not FileExists(uploadPath) Then
        Call objData.WriteToNTLog("No file", 2)
        Else
        Call objData.WriteToNTLog("Length 0", 2)
        End If
        Loop
        ' note that path to exe is quoted to allow spaces in path spec
        Call objData.WriteToNTLog("""" & GetImageMagickPath() & "convert"" """
        & uploadPath & """" & opStr & " """ & thumbPath & """", 4)
        End If

        WHY:confused: check C:\WriteLog.txt before wrting to the event log. I am sure the app use to log to that file then they changed it to log to the eventlog. But why leave the file check there? The app has a configuration file and why not set logging flag in the app configuration file. :confused: X| :mad:

        Yusuf

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

        A silly oversight perhaps, but not really a horror. On a really bad day i might have committed the same "atrocity" :laugh: A public-opinion poll is no substitute for thought.

        Y 1 Reply Last reply
        0
        • O oggenok64

          A silly oversight perhaps, but not really a horror. On a really bad day i might have committed the same "atrocity" :laugh: A public-opinion poll is no substitute for thought.

          Y Offline
          Y Offline
          Yusuf
          wrote on last edited by
          #4

          Søren Turin wrote:

          A silly oversight perhaps, but not really a horror. On a really bad day i might have committed the same "atrocity" Laugh

          I agree. The code it self is not horror. But debugging why the application is not logging with is horror. This was a code I inherited and I was not aware of this piece of code. I found it out after spending 2 days to figure out why the app was not logging to the eventlog. :sigh:

          Yusuf

          D 1 Reply Last reply
          0
          • Y Yusuf

            Søren Turin wrote:

            A silly oversight perhaps, but not really a horror. On a really bad day i might have committed the same "atrocity" Laugh

            I agree. The code it self is not horror. But debugging why the application is not logging with is horror. This was a code I inherited and I was not aware of this piece of code. I found it out after spending 2 days to figure out why the app was not logging to the eventlog. :sigh:

            Yusuf

            D Offline
            D Offline
            Donsw
            wrote on last edited by
            #5

            Could it be another application is writing to the file. and this is waiting for synchronization. bad programming with little comments. Not a real horror

            cheers, Donsw My Recent Article : Optimistic Concurrency with C# using the IOC and DI Design Patterns

            1 Reply Last reply
            0
            • Y Yusuf

              I am supporting a legacy asp/vb COM app X| with little or no documentation I upgraded a server with some bug fixes, as usual something did not work. roll sleeve up and let us dig for clue. The COM app logs extensively to the event log, but there is no single entry. I checked all settting and there is no configuration issues. I gave up and started to look into the code why it is not logging and I came across

              If FileExists("C:\WriteLog.Txt") Then
              Dim objData As New Data
              Dim icnt As Integer
              icnt = 0
              Do While Not FileExists(uploadPath) Or FileLen(uploadPath) = 0
              If Not FileExists(uploadPath) Then
              Call objData.WriteToNTLog("No file", 2)
              Else
              Call objData.WriteToNTLog("Length 0", 2)
              End If
              Loop
              ' note that path to exe is quoted to allow spaces in path spec
              Call objData.WriteToNTLog("""" & GetImageMagickPath() & "convert"" """
              & uploadPath & """" & opStr & " """ & thumbPath & """", 4)
              End If

              WHY:confused: check C:\WriteLog.txt before wrting to the event log. I am sure the app use to log to that file then they changed it to log to the eventlog. But why leave the file check there? The app has a configuration file and why not set logging flag in the app configuration file. :confused: X| :mad:

              Yusuf

              D Offline
              D Offline
              dojohansen
              wrote on last edited by
              #6

              Classical! Presumably the dev didn't understand or did not care to understand what the old code was doing and decided to leave it there "just in case". At my company we've got the full source history in a sourcesafe database (though we are finally moving on to Team System now), but a lot of people still attempt to keep a full version history in the latest version of the code - never removing anything, but commenting it out and usually adding their initials and the date and time, as if this would actually help anyone later on. In my view it just distracts, and is never really useful since it's far easier to compare versions in sourcesafe than comparing the comments to the current code. Well, at least they comment it out rather than leave the old code in there...

              Y 1 Reply Last reply
              0
              • D dojohansen

                Classical! Presumably the dev didn't understand or did not care to understand what the old code was doing and decided to leave it there "just in case". At my company we've got the full source history in a sourcesafe database (though we are finally moving on to Team System now), but a lot of people still attempt to keep a full version history in the latest version of the code - never removing anything, but commenting it out and usually adding their initials and the date and time, as if this would actually help anyone later on. In my view it just distracts, and is never really useful since it's far easier to compare versions in sourcesafe than comparing the comments to the current code. Well, at least they comment it out rather than leave the old code in there...

                Y Offline
                Y Offline
                Yusuf
                wrote on last edited by
                #7

                dojohansen wrote:

                but a lot of people still attempt to keep a full version history in the latest version of the code - never removing anything, but commenting it out and usually adding their initials and the date and time, as if this would actually help anyone later on. In my view it just distracts

                sometime, only on certain conditions, I leave old code behind commented out. Such as if I am making major logic change and what is change is not big piece of code I leave it for historical comparison. Beyond that I don't get it what the code needs to be polluted with old code. :|

                Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]

                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