How to get length of a file? MC++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Napcrisis
    New Member
    • Sep 2008
    • 8

    How to get length of a file? MC++

    Hi
    im running into alot of issues with mc++ and one of the problems is that i cannot get the length of the file. My objective is to erase a file so that it cannot be recovered by data recovery methods. So basically opens a file,get file length and overwrites all the bytes in file and repeatedly do this till user is happy.
    The project is created in CLR's windows form application.

    Btw, can any1 tell me what CLR and C++/CLI is about?
    I just started with .net and visual c++ things so im still new. Hope anybody can reply me.
    Thanks in advance
    Regards,
    Tommy
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Well the FileInfo object can be used to get the length of a file.
    As for your other questions, I recomend just reading a tutorial on the basics and such.

    Comment

    • Napcrisis
      New Member
      • Sep 2008
      • 8

      #3
      Thx for the reply
      i saw the length part of fileinfo but i do not know how to use it, can you show me?

      i came upon this filestream which seems to be able to readbyte and writebyte.. is it possible for me to read up a byte at a time and while its not EOF (\0) the program shall continue writing a random byte to it?
      regards
      Tom

      Comment

      • Barok
        New Member
        • Sep 2007
        • 10

        #4
        if this is what you looking for..
        Code:
                  FileInfo file = new FileInfo(filename);
                  int length = (int)file.Length;

        Comment

        • Napcrisis
          New Member
          • Sep 2008
          • 8

          #5
          ok ill try it out
          thanks

          Comment

          • Napcrisis
            New Member
            • Sep 2008
            • 8

            #6
            I got this error when i tried that method.

            error C2664: 'System::IO::Fi leInfo::FileInf o(System::Strin g ^)' : cannot convert parameter 1 from 'System::IO::Fi leInfo ^' to 'System::String ^'
            No user-defined-conversion operator available, or
            Types pointed to are unrelated; conversion requires reinterpret_cas t, C-style cast or function-style cast

            Any idea how to solve this? or whats causing this?

            Comment

            • Napcrisis
              New Member
              • Sep 2008
              • 8

              #7
              hmm kinda works now but still showing an error when i tried to use the length.Whats the right way of assigning this length to my variable? and what type to use?
              haha nvm i solve this part

              Comment

              • Plater
                Recognized Expert Expert
                • Apr 2007
                • 7872

                #8
                MSDN the object for the correct syntax using managed c++

                Comment

                Working...