C# validate contents of a file against another file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • saurabh9gupta
    New Member
    • Aug 2009
    • 52

    C# validate contents of a file against another file

    Hello All.

    I have 2 Files.
    File 1 - is a new file conataining some data and
    File 2 is a predefined file in the system

    Now when the user uploads his/her file for validation, I need to check each and every field in the uploaded file with file already present in the system.

    Can anyone guide on how to proceed on this!
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    I think we need a bit more in the way of details... what are some sample file contents, is the text going to be exact, are we looking at different order and formatting?

    The general idea should be simple enough though...

    Open file 1
    Open file 2
    Read first field in file 1
    Search for field in file 2
    Compare values
    Repeat for next field

    Comment

    • saurabh9gupta
      New Member
      • Aug 2009
      • 52

      #3
      Hi.
      The scenario is

      The first file which is to be validated will have some fields lets say n(of varying types like numeric,text etc.)
      The second file which will be the base file will have all the possible fields.

      The operations to be done are -
      1) Verify that the first file is having the same number of fields.
      2) Names of the fields MUST match.
      3) Data type should also match.

      Comment

      • GaryTexmo
        Recognized Expert Top Contributor
        • Jul 2009
        • 1501

        #4
        Ok, so it sounds like you've got a pretty good handle on what you want to do... what's your question?

        Do you need to know how to access files, or is there something else you're unsure about?

        Comment

        • saurabh9gupta
          New Member
          • Aug 2009
          • 52

          #5
          actually..
          i needed some help as in code to do it...
          though i have coded some logic but its not working..

          If any other logic is available on the net then I'd like to see it

          Comment

          • GaryTexmo
            Recognized Expert Top Contributor
            • Jul 2009
            • 1501

            #6
            I'm afraid I can't give you the code to do it... it's not my job to write your program for you. I've given you a pretty good outline and you've said you've got a good idea on what you want to do, so you just need to sit down and do it.

            I'm quite happy to help you debug any code you have and work through problems, I can't (and won't) write the code for you and post it here.

            I hope that seems reasonable...

            Comment

            Working...