Results 1 to 6 of 6

Thread: [RESOLVED] [02/03] Rename file successful?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    675

    Resolved [RESOLVED] [02/03] Rename file successful?

    Hello,
    I found a function called Rename, just simply Rename, that renames a file. It works, but is it bad to use that? Usually that seems to be the case with functions that aren't part of a namespace. Also, the user tries to rename a file to "////a//aa//" it will rename it to "aaa". I was hoping to have it do a literal renaming, which would break in that case, which I would handle.

    So, does anyone know of a better way to do renaming in 2003? The examples I found were in 2005.
    VB.Net 2008
    .Net Framework 2.0

    "Must you breathe? 'Cause I need heaven..."

  2. #2
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    2,012

    Re: [02/03] Rename file successful?

    This works in VB2005:
    My.Computer.FileSystem.RenameFile("C:\OldFilename.txt", "NewFilename.txt")

    Not sure if it works in 2003.

  3. #3
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [02/03] Rename file successful?

    Quote Originally Posted by nbrege
    This works in VB2005:
    My.Computer.FileSystem.RenameFile("C:\OldFilename.txt", "NewFilename.txt")

    Not sure if it works in 2003.
    That wont work in 2003, the My namespace doesnt exist.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    675

    Re: [02/03] Rename file successful?

    That is what I found in the 2005 posts. Unfortunately, there is no My namespace in 2003.
    VB.Net 2008
    .Net Framework 2.0

    "Must you breathe? 'Cause I need heaven..."

  5. #5
    Lively Member
    Join Date
    Oct 2006
    Posts
    88

    Re: [02/03] Rename file successful?

    Possibly, you could move, not rename the files. They do similar things.

    IO.File.Move(oldFileName, newFileName) may work

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    675

    Re: [02/03] Rename file successful?

    I think that will work computafreak. I was using copy and delete, and I thought about using move, but then I came across rename. Anyway, I got caught up in other problems with renaming and forgot about trying Move. Thanks.
    VB.Net 2008
    .Net Framework 2.0

    "Must you breathe? 'Cause I need heaven..."

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