Have a look at File.Copy()
Using File.Copy you can specify the new file name as part of the destination string.
So something like
File.Copy(@"c:\test.txt", @"c:\test\foo.txt");
See also How to: Copy, Delete, and Move Files and Folders (C# Programming Guide)
More Related Contents:
- Is there a way to check if a file is in use?
- Parsing CSV files in C#, with header
- What’s the fastest way to read a text file line-by-line?
- Easiest way to read from and write to files
- FileSystemWatcher vs polling to watch for file changes
- Saving any file to in the database, just convert it to a byte array?
- How do I create an Excel (.XLS and .XLSX) file in C# without installing Microsoft Office?
- How to both read and write a file in C#
- Download/Stream file from URL – asp.net
- How to read an entire file to a string using C#?
- The input is not a valid Base-64 string as it contains a non-base 64 character
- How to read the data in a wav file to an array
- Extremely Large Single-Line File Parse
- Uploading and Downloading large files in ASP.NET Core 3.1?
- Sharing violation IOException while reading and writing to file C#
- Can I simply ‘read’ a file that is in use?
- Is there a faster way than this to find all the files in a directory and all sub directories?
- can I check if a file exists at a URL?
- Can you keep a StreamReader from disposing the underlying stream?
- C#: Prepending to beginning of a file
- How can I read a text file without locking it?
- File Copy with Progress Bar
- Wait for file to be freed by process
- Unit Testing File I/O
- Can .NET load and parse a properties file equivalent to Java Properties class?
- How to get a MemoryStream from a Stream in .NET?
- Renaming a directory in C# [closed]
- Using StreamReader to check if a file contains a string
- Quickest way in C# to find a file in a directory with over 20,000 files
- how to handle spaces in file path if the folder contains the space?