Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB.NET copying and renaming a file

Posted on 2008-10-29
2
Medium Priority
?
1,382 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Accepted Solution

by:
TechTiger007 earned 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

721 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