CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Thread: reading a file

  1. #1
    Join Date
    Jul 2010
    Posts
    94

    Question reading a file

    I have to get all filepaths of C:\windows\system32\ into a vector of strings, and check their contents. I put this reading and checking in a worker thread but it always results in a Runtime error that the application has to stop in an unusual way

    For sometimes to other directories, it works, but sometimes fails with the same error message at the Crtdebug()...

    Code:
    For each file names
       Read its content
          check it against some critieria

  2. #2
    Join Date
    Jul 2010
    Posts
    94

    Re: reading a file

    Oh it should be something like this (clearer)

    Code:
    for each of the files (i=0;i<|files|-1)
       read the first file content
       for each of the files (j=i+1;j<|files|)
          read the second on
          if (content file 1 and content file 2 satisfy some criteria)
              printf ("Satisfy")
    I do this on Vista, VS10
    Last edited by Sharpie; October 10th, 2010 at 09:11 PM.

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: reading a file

    I am confused... Are you doing it using VB?
    Didn't you try to debug your code?
    Victor Nijegorodov

  4. #4
    Join Date
    Jul 2010
    Posts
    94

    Re: reading a file

    Quote Originally Posted by VictorN View Post
    I am confused... Are you doing it using VB?
    Didn't you try to debug your code?
    Thank you
    I think I am alittle out of my mind, not confused. I think I am writing this post in VC++
    and my mind is about VB.
    Anyway, debuging in my problem leads me nowhere, there are lots of files in that directory, do you know a technique to get me to the line where error occurs ?

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: reading a file

    Have a look at Call Stack window...
    Victor Nijegorodov

  6. #6
    Join Date
    Jul 2010
    Posts
    94

    Re: reading a file

    Oh I see it.
    A file in my vector doesn't have a full initialization, it doesn't have a file name, and other properties as included in my struct; all are named as <Bad struct> etc

    This is odd! Before running the thread above, I already put them all in my vector and it initialise correctly. What else should I do next ?

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: reading a file

    Quote Originally Posted by Sharpie View Post
    Oh I see it.
    A file in my vector doesn't have a full initialization, it doesn't have a file name, and other properties as included in my struct; all are named as <Bad struct> etc
    Sorry, I have no idea what your "vector" is and why it "doesn't have a full initialization".

    So, the only tip I can give you - debug your code step by step to see what where and why goes wrong...
    Victor Nijegorodov

  8. #8
    Join Date
    Jul 2010
    Posts
    94

    Re: reading a file

    Quote Originally Posted by VictorN View Post
    Sorry, I have no idea what your "vector" is and why it "doesn't have a full initialization".
    So, the only tip I can give you - debug your code step by step to see what where and why goes wrong...
    Ok don't worry about my vector contents, it only ails in the thread. You know, actually I don't even need to code this part
    When a user choose to look up what he wants in his windows drive, I can make a fake process as if the search has been done and finish the work sooner and cleaner. Your advice for me to step one by one over 17000 elements in my vector is really inappropriate, but I thank you for your input very much. Oh well I might be thinking I can step over a double loop with F5, which seemingly is unable to accomplish because the mentioned runtime error will just again show up, the whole debug process becomes exactly the same as running the program then, finally useless. I am bored!

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: reading a file

    Well, again: you didn't provide any useful/detailed description about your program, so don't expect any detailed help!
    Victor Nijegorodov

  10. #10
    Join Date
    Jul 2010
    Posts
    94

    Re: reading a file

    Quote Originally Posted by VictorN View Post
    Well, again: you didn't provide any useful/detailed description about your program, so don't expect any detailed help!
    Yes, the truth is that my programming skill is actually very bad.
    My teacher tells me that in real life, it's not really about how much one learns in school, it's about how much one can manage. Now I see it, that's really a good condolence for me to move on programming this application otherwise I should quit it.

  11. #11
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: reading a file

    Quote Originally Posted by Sharpie View Post
    My teacher tells me that in real life, it's not really about how much one learns in school, it's about how much one can manage.
    Correct!

    Quote Originally Posted by Sharpie View Post
    ... Now I see it, that's really a good condolence for me to move on programming this application otherwise I should quit it.
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured