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. delete files from c++ code

delete files from c++ code

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
6 Posts 5 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.
  • M Offline
    M Offline
    monageasmear
    wrote on last edited by
    #1

    i was trying system(del(filename)); but its giving error any ideas??? thanks

    G V E T 4 Replies Last reply
    0
    • M monageasmear

      i was trying system(del(filename)); but its giving error any ideas??? thanks

      G Offline
      G Offline
      Graham Bradshaw
      wrote on last edited by
      #2

      That's really going the long away around to delete a file. How about the DeleteFile function?

      1 Reply Last reply
      0
      • M monageasmear

        i was trying system(del(filename)); but its giving error any ideas??? thanks

        V Offline
        V Offline
        Verolix
        wrote on last edited by
        #3

        Try: #include <stdio.h> remove(const char *filename);

        1 Reply Last reply
        0
        • M monageasmear

          i was trying system(del(filename)); but its giving error any ideas??? thanks

          E Offline
          E Offline
          Erik Funkenbusch
          wrote on last edited by
          #4

          Del is not a program. It's a shell builtin, just like dir is. Thus, system doesn't know what Del is. There is no del.exe. Use DeleteFile if you're using Win32 code, or remove if using standard C code. -- Where are we going? And why am I in this handbasket?

          T 1 Reply Last reply
          0
          • E Erik Funkenbusch

            Del is not a program. It's a shell builtin, just like dir is. Thus, system doesn't know what Del is. There is no del.exe. Use DeleteFile if you're using Win32 code, or remove if using standard C code. -- Where are we going? And why am I in this handbasket?

            T Offline
            T Offline
            toxcct
            wrote on last edited by
            #5

            Erik Funkenbusch wrote: Del is not a program. It's a shell builtin, just like dir is. Thus, system doesn't know what Del is. There is no del.exe. del.exe doesn't exist, but system() doesn't launch programs. it executes shell's commands, just as del, dir, cls... if you try system("cls");, your screen (in console mode, of course) will be cleared... the problem in monageasmear's code is that he doesn't enclose the system()'s parameter into ""... cheers,


            TOXCCT >>> GEII power
            [toxcct][VisualCalc]

            1 Reply Last reply
            0
            • M monageasmear

              i was trying system(del(filename)); but its giving error any ideas??? thanks

              T Offline
              T Offline
              toxcct
              wrote on last edited by
              #6

              i think if you had written

              system("del filename");

              if would have worked. first, you must know the del shell's command syntax ; secondly, if you had a look at the MSDN, you would see that system() gets a LPCTSTR, it means a const TCHAR*, that's why i use a string parameter... and to finish, system() is not recommended, as Graham Bradshaw , [DFS] Zero and Erik Funkenbusch said...


              TOXCCT >>> GEII power
              [toxcct][VisualCalc]

              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