C# 找不到路径的一部分
我只想将Decrypt2015.txt文件写入logs.txt,但它会给我一个路径找不到的部分。有人能帮我吗?我能做什么您需要用:冒号指定驱动器号 试试这个:C# 找不到路径的一部分,c#,logging,encryption,filestream,C#,Logging,Encryption,Filestream,我只想将Decrypt2015.txt文件写入logs.txt,但它会给我一个路径找不到的部分。有人能帮我吗?我能做什么您需要用:冒号指定驱动器号 试试这个: private void btnDec_Click(object sender, EventArgs e) { string temp = ""; int i = 0; string listpath = @"c\yearsLog\2015.txt"; str
private void btnDec_Click(object sender, EventArgs e)
{
string temp = "";
int i = 0;
string listpath = @"c\yearsLog\2015.txt";
string writePath = @"c\logs.txt";
StreamReader file = new StreamReader(listpath);
long counter = CountLinesInFile(listpath);
for (i = 0; i < counter; i++)
{
temp = file.ReadLine().Replace("....", "");
CreateNewLogFiles(Decryption(temp),writePath);
}
file.Close();
MessageBox.Show("Log Dosyanız tamamlandı.");
}
解决方案2:
我已经使用了--string listpath=@c:\yearsLog\2015.txt;字符串writePath=@c:\logs.txt@好的,但在你的问题中,驱动器没有冒号letters@akdrmrk:确定您的C:drive中没有目录年slog首先检查我确定。我在C:@akdrmrk的yearsLog文件夹中有2015.txt:您可以使用文件检查文件是否存在。存在,请使用解决方案2尝试我编辑的答案,请告诉我结果
string listpath = @"c:\yearsLog\2015.txt";
string writePath = @"c:\logs.txt";
private void btnDec_Click(object sender, EventArgs e)
{
string temp = "";
int i = 0;
string listpath = @"c:\yearsLog\2015.txt";
if(File.Exists(listpath))
{
string writePath = @"c:\logs.txt";
StreamReader file = new StreamReader(listpath);
long counter = CountLinesInFile(listpath);
for (i = 0; i < counter; i++)
{
temp = file.ReadLine().Replace("....", "");
CreateNewLogFiles(Decryption(temp),writePath);
}
file.Close();
MessageBox.Show("Log Dosyanız tamamlandı.");
}
else
{
MessageBox.Show("File "+listpath+" not found");
}
}