private async void ClientOnFileIncomeEvent(string userId, string username, string originalFileName, string cryptedfileName) { string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "CryptedChatTemp"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var cryptedPath = Path.Combine(path, cryptedfileName); path = Path.Combine(path, originalFileName); var file = await Client.DownloadFile(cryptedfileName); if (File.Exists(path)) { File.Delete(path); } using (var fileStream = new FileStream(cryptedPath, FileMode.Create, FileAccess.Write)) { file.CopyTo(fileStream); } Cipher.DecryptFile(cryptedPath, path, Client.PassPhrase); File.Delete(cryptedPath); ChatBox.AppendHyperLink(username, originalFileName, _userColors[userId]); }