CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2011
    Posts
    4

    [RESOLVED] Renaming a file

    How would I go about doing that? I'm pretty sure it would take 2 parameters like this
    Code:
    renameMethod("originalFileName", "newFileName");
    But I do not know the method that renames files.

    EDIT:
    Nvrm found out how.

    Had to add
    Code:
    using System.IO;
    to the top then use
    Code:
    File.Move("originalFileName and directory", "NewfileNameAndDirectory");
    I just make the the dircetory the same and rename the file like so.
    Code:
    File.Move("C:\\Bender.txt", "C:\\Bender2.txt");
    and the renames "Bender.txt" to "Bender2.txt"
    Last edited by ThatBenderGuy; December 5th, 2011 at 11:52 PM.

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: [RESOLVED] Renaming a file

    Have a look at the System.IO.File class
    Always use [code][/code] tags when posting code.

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