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

    How to rename a file?

    Hello,

    I would want to know how to rename a file.

    Thank you for your responses
    best regards
    philippe gendreau


  2. #2
    Join Date
    Jan 2000
    Location
    CA
    Posts
    52

    Re: How to rename a file?

    If the file is one that you are renaming using VB, the syntax is

    [vbcode]

    Name oldname as newname

    [\vbcode\

    Just be sure to include the complete path in the oldname and newname values.

    Example:

    [vbcode]

    Name "C:\My Documents\JunkDrawer.dat" as "C:\My Documents\UsefulStuff.dat"

    [\vbcode]

    Good luck...


  3. #3
    Join Date
    Dec 1999
    Posts
    13

    Re: How to rename a file?

    hello,

    thank you for your response.

    But i want to rename a file with a instruction like "kill FileName"
    A instrucction like "Rename Filename"

    best regards
    philippe gendreau


  4. #4
    Join Date
    Dec 1999
    Posts
    128

    Re: How to rename a file?

    What do you mean? When you rename a file, you must provide both the old and the new filename. There is no other way. JimmyT's suggestion is the only one. Unless the new filename is always constant. If that's the case, you can create a function in which you pass the old filename only as a parameter and it renames it to the constant. Is that what you want?

    -------------------------
    Nick A.

  5. #5
    Guest

    Re: How to rename a file?

    Hello,

    Sorry i don't understand the response.
    this is what i know to do:

    'close the file
    Close #1

    'open the file
    Open sPathModele For Input As #1

    'remove the file
    Kill sPathModele

    and what i don't know
    'rename the file ?????????



    thank your for your responses (sorry for my poor english)

    best regards
    Philippe gendreau




  6. #6
    Join Date
    Dec 1999
    Posts
    128

    Re: How to rename a file?

    Now i think i understand what you want.

    You must give the filename of the file you want to rename like JimmyT said.

    Name "C:\My Documents\OldFileName" as "C:\My Documents\NewFileName"



    Kill works the same way:

    Kill "C:\My Documents\MyFile"



    You cannot do the following:

    dim sPathModele as Integer
    Open sPathModele for input as #1
    Kill sPathModele



    It is wrong.

    -------------------------
    Nick A.

  7. #7
    Guest

    Re: How to rename a file?

    Ok Name works great
    thanks


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