本文介绍了如何移动有没有文件扩展名的文件? C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
if (File.Exists(@"C:\\Users" + Environment.UserName + "\\Desktop\\test"))
{ /\
this file has no file extension
}
的
文件测试
没有扩展和我需要帮助来移动或用此文件的东西有扩展
The file test
has no extension and I need help to either move or rename this file to something with a extension
推荐答案
没有扩展名的对功能无影响。
此外,重命名为真正的变相刚刚一动,所以你想要做的就是
Having no extension has no bearing on the function.Also, a rename is really just a move "in disguise", so what you want to do is
File.Move(@"C:\Users\Username\Desktop\test", @"C:\Users\Username\Desktop\potato.txt")
请承担@,因为你也没能逃脱反斜线。
Please bear in mind the @ before the string, as you haven't escaped the backslashes.
这篇关于如何移动有没有文件扩展名的文件? C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!