Change a txt file to exe
0. Documents
1. Code
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.IO;4 usingSystem.Linq;5 usingSystem.Text;6 usingSystem.Threading.Tasks;7 8 namespaceConsoleApplication49 {Ten class Program One { A Static voidMain (string[] args) - { - stringPath =@"d:\ User directory \ My Documents \visual Studio 2015\projects\consoleapplication4\consoleapplication4\bin\debug\2.txt"; the stringStr= path.changeextension (Path,". EXE"); - - Console.WriteLine (str); - Console.readkey (); + } - } +}
2. Control Station
3. Documents
See the wood? There are no changes to the files stored in the computer. So what did the method in the path class do?
In fact, this method is to modify the string, not to modify the files on the computer.
Using System;
Using System.Collections.Generic;
Using System.IO;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks;
Namespace ConsoleApplication4
{
Class Program
{
static void Main (string[] args)
{
string path = @ "D:\ User directory \ My Documents \visual Studio 2015\projects\consoleapplication4\consoleapplication4\bin\debug\2.txt";
String str= path.changeextension (Path, ". exe");
Console.WriteLine (str);
Console.readkey ();
}
}
}
C # Console Foundation path.changeextension file name extension in a path string