Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1384
  • Last Modified:

VB.NET copying and renaming a file

I need help in VB.NET to copy a file, rename it, and then put it in another folder.  If that file already exists, it will overwrite without prompting.  

For example file 22288Bank10292008_a3322.csv was downloaded.   The user will be able to use the OpenFileDialog1 to open this file from any where they save the file to.  From there, the program will take the file and copy, rename to input.csv, and put it in C:\Input\ folder.  There's a third party tool that we'll use to inport this into our ERP system and the tool only recognize file input.csv.

I looked online, but only found the script:  My.Computer.FileSystem.RenameFile(oldfilename, newfilename)
0
holemania
Asked:
holemania
1 Solution
 
TechTiger007Commented:
Try this

System.IO.File.Copy("<source file path>","<destination file path>",true)

Eg: if your file name is oldfile.txt and you want to rename it to newfilename.txt

then use System.IO.File.Copy("D:\PickupFolder\oldfile.txt", "C:\Input\folder\newfilename.txt", true)

this will copy and rename the file and overwrite if file already exist
0
 
holemaniaAuthor Commented:
Sweet thanks.  That worked.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now