Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8013007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:30:33+00:00 2026-06-04T19:30:33+00:00

So i have a bit of code that uses Dos Commands to try to

  • 0

So i have a bit of code that uses Dos Commands to try to rename a folder. So

system("rename C:\\Users\\me\\SecondDir NewDir);

So this tries to rename SecondDir to NewDir. There is already a folder at that location called NewDir so it should fail. And it does. Im then using GetLastError to get the error code returned to ensure the problem is what i expect it to be. But it only ever returns ERROR_NO_MORE_FILES. Which isnt the error i should be getting, which is ERROR_ALREADY_EXISTS. Im assuming this is something to do with using the system command?

EDIT: I just checked and i even get ERROR_NO_MORE_FILES returned when a command is successful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T19:30:35+00:00Added an answer on June 4, 2026 at 7:30 pm

    GetLastError will not return a meaningful value except in the circumstances where it is documented to do so. This is not one of them – the values you are getting are irrelevant and intended for someone else.

    To rename a file from C you should use the C runtime rename function not use system to invoke a rename utility.

    GetLastError is only meaningful immediately after calling a Win32 function which is documented to set the thread Last Error using SetLastError. The C equivalent is errno, which applies to C functions.

    The rename function returns -1 on failure and sets errno.

    E.g.: http://msdn.microsoft.com/en-us/library/zw5t957f(v=VS.80).aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I have this small bit of code that generates rows and columns of
I have inherited a bit of Java code that uses Hibernate. Some of the
i have a bit of aspx code that uses Eval to generate a call
I have a bit of COM code that uses interface pointers. The original author
i have bit of code that causes an underflow: var t1, t2, delta: DWORD:
I have a bit of code that formats an editing page depending on how
I have a bit of code that tells you when a contact would not
I have a bit of code that concatenates text from some input boxes and
Using Ipython notebook and the pandas module, I have a bit of code that
I have a bit of Javascript code that creates a save friendly version of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.