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. Check Broken File

Check Broken File

Scheduled Pinned Locked Moved C#
questioncsharpdatabase
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.
  • D Offline
    D Offline
    dataminers
    wrote on last edited by
    #1

    How can I check file is broken? I want to get alarm when text file or .sdf (database file) file is broken in specified directory. How can I check it in C#? Thanks...

    R L 2 Replies Last reply
    0
    • D dataminers

      How can I check file is broken? I want to get alarm when text file or .sdf (database file) file is broken in specified directory. How can I check it in C#? Thanks...

      R Offline
      R Offline
      R Giskard Reventlov
      wrote on last edited by
      #2

      What do you mean by broken?

      "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

      D 1 Reply Last reply
      0
      • R R Giskard Reventlov

        What do you mean by broken?

        "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

        D Offline
        D Offline
        dataminers
        wrote on last edited by
        #3

        damaged file.

        R 1 Reply Last reply
        0
        • D dataminers

          damaged file.

          R Offline
          R Offline
          R Giskard Reventlov
          wrote on last edited by
          #4

          You'd need to have something to compare it to; the original, undamaged file then carry out a byte-by-byte comparison. You could create a checksum of the original file and store that then compare that to the checksum of the damaged file. You could also compare file lengths; if they are different then so are the files (obviously). If you don't have the original file to compare to then you might be a bit stuck unless the damage you are looking for is quite specific and testable.

          "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

          L 1 Reply Last reply
          0
          • R R Giskard Reventlov

            You'd need to have something to compare it to; the original, undamaged file then carry out a byte-by-byte comparison. You could create a checksum of the original file and store that then compare that to the checksum of the damaged file. You could also compare file lengths; if they are different then so are the files (obviously). If you don't have the original file to compare to then you might be a bit stuck unless the damage you are looking for is quite specific and testable.

            "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            digital man wrote:

            If you don't have the original file to compare to then you might be a bit stuck unless the damage you are looking for is quite specific and testable.

            That's testing whether the .sdf has changed, compared to the original. It's probably a SqlCE database, and it's checksum would change on every update/delete.

            I are Troll :suss:

            1 Reply Last reply
            0
            • D dataminers

              How can I check file is broken? I want to get alarm when text file or .sdf (database file) file is broken in specified directory. How can I check it in C#? Thanks...

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              dataminers wrote:

              How can I check file is broken?

              Define "broken"; a textfile may contain any character, printable or not. Does the textfile have a specific format that you can compare against? The SqlCe database is somewhat easier to verify, and that's documented over here[^] :)

              I are Troll :suss:

              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