CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Guest

    Renaming directories?

    Is there an MFC/Win32 command to rename a directory? The documentation says CFile::Rename won't do the job.



  2. #2
    Join Date
    May 1999
    Posts
    29

    Re: Renaming directories?

    Hi!
    The rename or the _wrename function(defined in stdio.h) renames the file or directory specified by oldname to the name given by newname.

    The prototypes are :
    int rename( const char *oldname, const char *newname );

    int _wrename( const wchar_t *oldname, const wchar_t *newname );

    Example :

    /* RENAMER.C: This program attempts to rename a file
    * named RENAMER.OBJ to RENAMER.JBO. For this operation
    * to succeed, a file named RENAMER.OBJ must exist and
    * a file named RENAMER.JBO must not exist.
    */

    #include <stdio.h>

    void main( void )
    {
    int result;
    char old[] = "RENAMER.OBJ", new[] = "RENAMER.JBO";

    /* Attempt to rename file: */
    result = rename( old, new );
    if( result != 0 )
    printf( "Could not rename '%s'\n", old );
    else
    printf( "File '%s' renamed to '%s'\n", old, new );
    }
    Refer the help for more info.

    Do let me know if this solves your problem.

    Regards,
    Sukanya Swaminathan
    Software Engineer
    Aditi Technologies Pvt. Ltd
    224/16,Ramana Maharishi Road,
    Blr - 80



  3. #3
    Guest

    Re: Renaming directories?

    Thanks! It worked out perfectly!

    Regards,
    Gabriel



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured