By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,294 Members | 2,484 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,294 IT Pros & Developers. It's quick & easy.

Chaning a file's extension

P: 16
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.Rename(fullpathofoldfile, fullpathofnewfile)
Microsoft.VisualBasic.Rename(foldfile, fullpathofnewfile)
My.Computer.FileSystem.RenameFile(foldfile, fullpathofnewfile)

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.
Jul 31 '09 #1
Share this Question
Share on Google+
1 Reply


MrMancunian
Expert 100+
P: 569
Hi, this might not be the most elegant solution, but it sure works:

Expand|Select|Wrap|Line Numbers
  1. Dim Path As String = "C:\"
  2. Dim strFileName As String = "test.csv"
  3. strFileName = strFileName.Replace(".csv", "")
  4. My.Computer.FileSystem.RenameFile(Path & strFileName & ".txt", strFileName & ".imp")
Steven
Jul 31 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.