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 / C++ / MFC
  4. Any fast File read/write method?

Any fast File read/write method?

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 Posts 6 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Dear all, Anybody knows a fastest file read/write method? It is because i am doing a program and need to read/write a same file many many times, using CFile to read/write is very very slow. Any suggest method? Andy

    M A P M 4 Replies Last reply
    0
    • L Lost User

      Dear all, Anybody knows a fastest file read/write method? It is because i am doing a program and need to read/write a same file many many times, using CFile to read/write is very very slow. Any suggest method? Andy

      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #2

      There is also FILE structure for doing that but I don't know if it is faster than CFile. Mazy "The path you tread is narrow and the drop is shear and very high, The ravens all are watching from a vantage point near by, Apprehension creeping like a choo-train uo your spine, Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd

      1 Reply Last reply
      0
      • L Lost User

        Dear all, Anybody knows a fastest file read/write method? It is because i am doing a program and need to read/write a same file many many times, using CFile to read/write is very very slow. Any suggest method? Andy

        A Offline
        A Offline
        Alwin75
        wrote on last edited by
        #3

        An alternative is to use memory-mapped files, for which some examples can be found on the Microsoft knowledge base. There also exists a sample called ProcessWalker. The downside is that it only works on NT or higher (I believe). Alwin

        P 1 Reply Last reply
        0
        • A Alwin75

          An alternative is to use memory-mapped files, for which some examples can be found on the Microsoft knowledge base. There also exists a sample called ProcessWalker. The downside is that it only works on NT or higher (I believe). Alwin

          P Offline
          P Offline
          Paul M Watt
          wrote on last edited by
          #4

          Memory mapped files work for all Win32 operating systems.


          Build a man a fire, and he will be warm for a day
          Light a man on fire, and he will be warm for the rest of his life!

          1 Reply Last reply
          0
          • L Lost User

            Dear all, Anybody knows a fastest file read/write method? It is because i am doing a program and need to read/write a same file many many times, using CFile to read/write is very very slow. Any suggest method? Andy

            P Offline
            P Offline
            Peter Molnar
            wrote on last edited by
            #5

            why don't you try this in pure c? e.g.:

            FILE *fp1;
            char word[100];
            char c;

            fp1 = fopen("yourfile.txt", "r");

            do
            {
            c = fscanf(fp1, "%s", word); // read a word
            DoSomethingWith(word);
            }while (c != EOF); // until end of file

            fclose(fp1);

            Bunburry

            P 1 Reply Last reply
            0
            • P Peter Molnar

              why don't you try this in pure c? e.g.:

              FILE *fp1;
              char word[100];
              char c;

              fp1 = fopen("yourfile.txt", "r");

              do
              {
              c = fscanf(fp1, "%s", word); // read a word
              DoSomethingWith(word);
              }while (c != EOF); // until end of file

              fclose(fp1);

              Bunburry

              P Offline
              P Offline
              Paul M Watt
              wrote on last edited by
              #6

              A memory mapped file will still be faster because you will be accessing the file directly in memory. You will have a pointer that points directly to the buffer that contains the file.


              Build a man a fire, and he will be warm for a day
              Light a man on fire, and he will be warm for the rest of his life!

              1 Reply Last reply
              0
              • L Lost User

                Dear all, Anybody knows a fastest file read/write method? It is because i am doing a program and need to read/write a same file many many times, using CFile to read/write is very very slow. Any suggest method? Andy

                M Offline
                M Offline
                Matt Gullett
                wrote on last edited by
                #7

                I believe the multi-media IO functions provide the fastest file read/write performance on windows. Check out the mmioOpen function and all of its associated functions. In an app I developed a couple of years ago, my tests showed that mmio outperformed every other method. I don't have the stats for just how much, but it was enough to make a difference. My 2 cents. Matt Gullett

                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