2013-12-06 2 views
0
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ı."); 


    } 

Я хочу только написать файл с расшифровкой (2015.txt) в файл logs.txt, но он будет отсылать мне часть пути и не найти. Может кто-нибудь мне помочь? что я могу сделатьчасть пути не найден

ответ

0

Вы должны указать Drive письма с : двоеточием

Попробуйте:

string listpath = @"c:\yearsLog\2015.txt"; 
string writePath = @"c:\logs.txt"; 

Решение 2:

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

    } 
+0

Я уже использую ---- - string listpath = @ "c: \ yearsLog \ 2015.txt"; строка writePath = @ "c: \ logs.txt"; – Bub

+0

@akdrmrk: хорошо, но в вашем вопросе нет 'двоеточия' для букв дисков –

+0

может кто-нибудь мне помочь? – Bub

Смежные вопросы