File rename and delete

  • Thread starter Thread starter Patrick de Ridder
  • Start date Start date
P

Patrick de Ridder

This is rather elementary but I cannot find it anywhere.
How do you rename a file from within a program in C# ? (In the directory I
mean.)
How do you delete a file from within a program in C# ?
(I don't mean renaming a file while in the IDE).

Thanks.
 
Patrick de Ridder said:
This is rather elementary but I cannot find it anywhere.
How do you rename a file from within a program in C# ? (In the directory I
mean.)
How do you delete a file from within a program in C# ?
(I don't mean renaming a file while in the IDE).

Look at File.Delete and File.Move. (The full classname is
System.IO.File)
 
Hi Patrick,

You rename a file by moving it. Take a look at

File.Move()
File.Delete()

Happy coding!
Morten Wennevik [C# MVP]
 
Hi Patrick,

You rename a file by moving it. Take a look at

File.Move()
File.Delete()

Happy coding!
Morten Wennevik [C# MVP]
 
File.Move() works great, except when you're using a FileSystemWatcher
to watch for the Renamed event. Any clue how to rename a file using C#
so that the FileSystemWatcher.Renamed event is raised?

Bob Dover
Dover Technology Services
 
Back
Top