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. "Displaying a file"

"Displaying a file"

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
13 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.
  • H Offline
    H Offline
    harsh_2961
    wrote on last edited by
    #1

    Hi, If iknow the filename and its path i hould be able to open and display that file.if any ideas on how to do it please let me know.. harsha

    H P P 3 Replies Last reply
    0
    • H harsh_2961

      Hi, If iknow the filename and its path i hould be able to open and display that file.if any ideas on how to do it please let me know.. harsha

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      Which? Open a file or get path of a file?


      WhiteSky


      H 1 Reply Last reply
      0
      • H harsh_2961

        Hi, If iknow the filename and its path i hould be able to open and display that file.if any ideas on how to do it please let me know.. harsha

        P Offline
        P Offline
        Programm3r
        wrote on last edited by
        #3

        Have you tried the following: Open FileHANDLE CreateFile( LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile );
        Read Contents:BOOL ReadFile( HANDLE hFile, // handle of file to read LPVOID lpBuffer, // pointer to buffer that receives data DWORD nNumberOfBytesToRead, // number of bytes to read LPDWORD lpNumberOfBytesRead, // pointer to number of bytes read LPOVERLAPPED lpOverlapped // pointer to structure for data );
        Read File[^] Open File[^] Regards,


        The only programmers that are better than C programmers are those who code in 1's and 0's..... :) :) Programm3r
        My Blog: ^_^

        H 1 Reply Last reply
        0
        • H Hamid Taebi

          Which? Open a file or get path of a file?


          WhiteSky


          H Offline
          H Offline
          harsh_2961
          wrote on last edited by
          #4

          i should be able to open and display the contents to the user .. harsha

          H 1 Reply Last reply
          0
          • P Programm3r

            Have you tried the following: Open FileHANDLE CreateFile( LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile );
            Read Contents:BOOL ReadFile( HANDLE hFile, // handle of file to read LPVOID lpBuffer, // pointer to buffer that receives data DWORD nNumberOfBytesToRead, // number of bytes to read LPDWORD lpNumberOfBytesRead, // pointer to number of bytes read LPOVERLAPPED lpOverlapped // pointer to structure for data );
            Read File[^] Open File[^] Regards,


            The only programmers that are better than C programmers are those who code in 1's and 0's..... :) :) Programm3r
            My Blog: ^_^

            H Offline
            H Offline
            harsh_2961
            wrote on last edited by
            #5

            i dont want to read or open or create a file.. i want to display a file to the user say when user clicks a button. will this help in that regard ? harsha

            N H 2 Replies Last reply
            0
            • H harsh_2961

              Hi, If iknow the filename and its path i hould be able to open and display that file.if any ideas on how to do it please let me know.. harsha

              P Offline
              P Offline
              prasad_som
              wrote on last edited by
              #6

              If its a simple text file using CEditView will do, try creating simple SDI application and choose baseclass as CEditView in last step of app wizard.

              Prasad Notifier using ATL | Operator new[],delete[][^]

              H 1 Reply Last reply
              0
              • H harsh_2961

                i should be able to open and display the contents to the user .. harsha

                H Offline
                H Offline
                Hamid Taebi
                wrote on last edited by
                #7

                Use of CFile::Read


                WhiteSky


                1 Reply Last reply
                0
                • P prasad_som

                  If its a simple text file using CEditView will do, try creating simple SDI application and choose baseclass as CEditView in last step of app wizard.

                  Prasad Notifier using ATL | Operator new[],delete[][^]

                  H Offline
                  H Offline
                  harsh_2961
                  wrote on last edited by
                  #8

                  its a ".chm" (Compiled Html file).. harsha

                  H D 2 Replies Last reply
                  0
                  • H harsh_2961

                    its a ".chm" (Compiled Html file).. harsha

                    H Offline
                    H Offline
                    Hamid Taebi
                    wrote on last edited by
                    #9

                    Use of HtmlHelp


                    WhiteSky


                    1 Reply Last reply
                    0
                    • H harsh_2961

                      i dont want to read or open or create a file.. i want to display a file to the user say when user clicks a button. will this help in that regard ? harsha

                      N Offline
                      N Offline
                      Newbie00
                      wrote on last edited by
                      #10

                      harsh_2961 wrote:

                      i dont want to read or open or create a file.. i want to display a file to the user say when user clicks a button. will this help in that regard ?

                      If you want to see file's content you have to open it. There is no other way than opening given file to read it, and if you want to display it's content you have to read it first. Unless you are talking about viewing file's... name? :^)

                      1 Reply Last reply
                      0
                      • H harsh_2961

                        i dont want to read or open or create a file.. i want to display a file to the user say when user clicks a button. will this help in that regard ? harsha

                        H Offline
                        H Offline
                        Hamid Taebi
                        wrote on last edited by
                        #11

                        Hope I understood your question use of a CFileDailog and when he clicks ok button show file name(Is your purpose)


                        WhiteSky


                        1 Reply Last reply
                        0
                        • H harsh_2961

                          its a ".chm" (Compiled Html file).. harsha

                          D Offline
                          D Offline
                          David Crow
                          wrote on last edited by
                          #12

                          Have you considered using ShellExecute(..., "open", "file.chm", ...)?


                          "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                          "Judge not by the eye but by the heart." - Native American Proverb

                          H 1 Reply Last reply
                          0
                          • D David Crow

                            Have you considered using ShellExecute(..., "open", "file.chm", ...)?


                            "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                            "Judge not by the eye but by the heart." - Native American Proverb

                            H Offline
                            H Offline
                            harsh_2961
                            wrote on last edited by
                            #13

                            thanks a lot.. its working perfectly:)

                            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