Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 找不到路径的一部分_C#_Logging_Encryption_Filestream - Fatal编程技术网

C# 找不到路径的一部分

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

我只想将Decrypt2015.txt文件写入logs.txt,但它会给我一个路径找不到的部分。有人能帮我吗?我能做什么

您需要用:冒号指定驱动器号

试试这个:

    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");
        }

    }