Solved

VB.NET copying and renaming a file

Posted on 2008-10-29
2
1,342 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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 …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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

21 Experts available now in Live!

Get 1:1 Help Now