【发布时间】:2012-01-17 18:23:26
【问题描述】:
所以我的上一个问题不清楚,所以这是我的第二次尝试。
当我将我的 txt 文件拖放到控制台中时,我会得到这样的路径:
"C:\Dokumente und Einstellungen\Bektas\Desktop\test\text1.txt"
如何自动删除" 字符?
在将路径保存到字符串之前,我必须手动删除它...
这是我的代码:
static void Main(string[] args)
{
String pfad;
String pfad2;
String speichern = "C:\\Dokumente und Einstellungen\\Bektas\\Desktop\\test\\ausgabe.txt";
try
{
Console.WriteLine("Pfad eingeben: ");
pfad = Console.ReadLine();
Console.WriteLine("Pfad eingeben: ");
pfad2 = Console.ReadLine();
// Input
List<String> data = File.ReadAllLines(pfad)
.Concat(File.ReadAllLines(pfad2))
.Distinct().ToList();
// Processing
data.Sort();
// Output
Console.WriteLine("Duplikate entfernt & sortiert:");
data.ForEach(Console.WriteLine);
File.WriteAllLines(speichern, data.ToArray());
}
catch (Exception e)
{
Console.WriteLine("Die Anwendung schlug fehl: {0}\t" + e.ToString());
}
Console.ReadKey();
}
}
【问题讨论】:
-
您能具体说明您的问题吗?你在哪里删除字符?
标签: c# console special-characters