2016-03-21 127 views
0

嗨,大家好我試圖使用c#.net和使用Web客戶端來查找和從網站上託管的.txt中讀取字符串的登錄表單。這是迄今爲止的代碼。任何幫助或鏈接將是有益的,因爲我不知道在哪裏看?使用Web客戶端登錄表單?

 WebClient webClient = new WebClient(); 
     String version = webClient.DownloadString("http://prostresser.xyz/psnservices/version.txt"); 
     label2.Text = version; 

     if (label1.Text == label2.Text) 
     { 

     } 
     else 
     { 

      DialogResult result = MessageBox.Show("there is a new update for ProjectRTM" + Environment.NewLine + "would you like to update?", 
    "update", MessageBoxButtons.YesNo, 
     MessageBoxIcon.Information); 
      if (result == DialogResult.Yes) 
      { 

       WebClient Client = new WebClient(); 
       Client.DownloadFileAsync(new Uri("http://prostresser.xyz/psnservices/update.rar"), Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "update.rar"); 


      } 
      else if (result == DialogResult.No) 
      { 

      } 
      else 
      { 

      } 

     } 
     if (Directory.Exists(user) && Directory.Exists(pass)) 
     { 
      metroTextBox1.Text = File.ReadAllText(user, Encoding.ASCII); 
      metroTextBox2.Text = File.ReadAllText(pass, Encoding.ASCII); 
     } 
    } 

回答

0

下載你的RAR文件後,你應該提取它。您可以使用Chilkat

Chilkat.Rar rar = new Chilkat.Rar(); 

// Note: The Chilkat RAR functionality only provides the ability 
// to open, list, and "unrar" (i.e. extract) RAR archives. It does 
// not provide the ability to create RAR archives. 

// Also, the Chilkat RAR functionality is free. It does not 
// require a license to use indefinitely. 

bool success; 
string location = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "update.rar"; 
string unzipLocation = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/update/"; 
success = rar.Open(location); 
if (success != true) { 
    MessageBox.Show(rar.LastErrorText); 
    return; 
} 

success = rar.Unrar(unzipLocation); 
if (success != true) { 
    MessageBox.Show(rar.LastErrorText); 
} 
else { 
    MessageBox.Show("Success."); 
    // Use file stream to load your text file. Find the matching username and password as needed. Figure that out since it varies depending on the format of the content of your text file. 
    // Other processing 
}