Solved

VB.NET copying and renaming a file

Posted on 2008-10-29
2
1,346 Views
Last Modified: 2008-10-29
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
Comment
Question by:holemania
2 Comments
 
LVL 13

Accepted Solution

by:
TechTiger007 earned 500 total points
ID: 22831972
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
 

Author Comment

by:holemania
ID: 22833153
Sweet thanks.  That worked.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Closing all open child forms. 4 38
DataGridView Events ? 3 37
fso.FolderExists("\\server\HiddenFolder$") 4 51
Get Top Visible Row of Datagridview 6 27
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now