Re: changing a filename in C#
From: Justin Rogers (Justin_at_games4dotnet.com)
Date: 03/06/04
- Next message: Justin Rogers: "Re: Asynchronous Socket Problem"
- Previous message: Eric Lawrence [MSFT]: "Re: Using NetworkCredential then a Redirect to the site requiring the credientails"
- In reply to: J. Marshall Latham: "changing a filename in C#"
- Next in thread: J. Marshall Latham: "Re: changing a filename in C#"
- Reply: J. Marshall Latham: "Re: changing a filename in C#"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 5 Mar 2004 22:46:06 -0800
FileInfo original = new FileInfo(pathToFile);
if ( original.Exists ) {
// If the destination already exists then this won't copy.
// This is to protect other files when performing the operation.
original.CopyTo(Path.ChangeExtension(original.FullName, ".txt"), false);
}
-- Justin Rogers DigiTec Web Consultants, LLC. Blog: http://weblogs.asp.net/justin_rogers "J. Marshall Latham" <marshall@networkip.net> wrote in message news:uDAhaB0AEHA.1516@TK2MSFTNGP10.phx.gbl... > I can't seem to find any resources to help me change a filename using C#. I > see a Path.ChangeExtension, but it only takes the full path as a string and > changes that string. It doesn't actually change the file (at least not from > what I have seen). I tried moving the file into the same directory with a > different name and totally lost my file. I am about to try moving it to > another directory and then moving it back with the new name. All I really > want to do is change the extension on the file from .tmp to .txt. Can > someone tell me how I can use C# code to change the name of a file. I > apologize if this is too elementary for this news group. > > Thanks for your help, > > JML > >
- Next message: Justin Rogers: "Re: Asynchronous Socket Problem"
- Previous message: Eric Lawrence [MSFT]: "Re: Using NetworkCredential then a Redirect to the site requiring the credientails"
- In reply to: J. Marshall Latham: "changing a filename in C#"
- Next in thread: J. Marshall Latham: "Re: changing a filename in C#"
- Reply: J. Marshall Latham: "Re: changing a filename in C#"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|