如何移动没有文件扩展名的文件?C#

use*_*030 2 c# io file

if (File.Exists(@"C:\\Users" + Environment.UserName + "\\Desktop\\test"))
{                                                                /\
                                               this file has no file extension
}          
Run Code Online (Sandbox Code Playgroud)

该文件test没有扩展名,我需要帮助将此文件移动或重命名为具有扩展名的文件

Das*_*nko 8

没有扩展与功能无关.此外,重命名实际上只是"伪装"的举动,所以你想要做的是

File.Move(@"C:\Users\Username\Desktop\test", @"C:\Users\Username\Desktop\potato.txt")
Run Code Online (Sandbox Code Playgroud)

请记住字符串前面的@,因为你还没有逃过反斜杠.