Chaning a file's extension

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mwcapps
    New Member
    • Mar 2009
    • 16

    Chaning a file's extension

    I'm writing an import application that import .csv files into my SQL Server 2005 database. When the import is complete I need to change that files extension from .csv to .imp with the same path. I've tried using the following:

    FileSystem.Rena me(fullpathofol dfile, fullpathofnewfi le)
    Microsoft.Visua lBasic.Rename(f oldfile, fullpathofnewfi le)
    My.Computer.Fil eSystem.RenameF ile(foldfile, fullpathofnewfi le)

    All attempts are giving back an error or 'Procedure or argument is invalid'. I have full access and permission to all files in all paths.
  • MrMancunian
    Recognized Expert Contributor
    • Jul 2008
    • 569

    #2
    Hi, this might not be the most elegant solution, but it sure works:

    Code:
    Dim Path As String = "C:\"
    Dim strFileName As String = "test.csv"
    strFileName = strFileName.Replace(".csv", "")
    My.Computer.FileSystem.RenameFile(Path & strFileName & ".txt", strFileName & ".imp")
    Steven

    Comment

    Working...