我正在尝试使用C#在Visual Studio中创建控制台应用程序,以便能够将.txt文件拖放到.exe文件上,并在该文件中查找和替换。最终我还希望能够将其保存为原始文件名后面加上_unwrapped的文件名。我对C#非常陌生,这是我所拥有的。它可以在我放置在调试文件夹中的测试文件上工作。如何使其与拖动的文件一起工作?我尝试了一些在谷歌上发现的方法,但它们没有起作用,而且我也不理解它们。谢谢!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
string text = File.ReadAllText("test.txt");
text = text.Replace("~", "~\r\n");
File.WriteAllText("test.txt", text);
}
}
}