I have a program given below. I wanna process multiple text file at once and display the result in different text file.
Please help.
namespace TMSDescriptionSample
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string error = "";
string encryptedText = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "input.txt");
string decryptedText = TMSDecryptionAPI.DecryptString(encryptedText, ref error); //pass the encrypted text to this function and it will return the decrypted text.
File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "ouput.txt", decryptedText);
MessageBox.Show("Done");
}
}
}

VulpesRank #55 · 29.2K reputationPosted Dec 23, 2014, 12:52 AM EST
If this takes too long or makes the UI unresponsive, then you may need to consider using background threads to spread the load.
Robin Bura167 reputationPosted Dec 23, 2014, 1:12 AM EST
Input files are many from a directory and output should be one.
Here is code i designed for two input files
VulpesRank #55 · 29.2K reputationPosted Dec 23, 2014, 1:53 AM EST
Robin Bura167 reputationPosted Dec 23, 2014, 2:07 AM EST
VulpesRank #55 · 29.2K reputationPosted Dec 23, 2014, 2:16 AM EST
If you want to ensure that the decrypted text for each file starts on a new line in output.txt, you could change:
File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "output.txt", decryptedText);
to:
File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "output.txt", decryptedText + Environment.NewLine);
Robin Bura167 reputationPosted Dec 23, 2014, 2:24 AM EST
VulpesRank #55 · 29.2K reputationPosted Dec 23, 2014, 2:37 AM EST
Robin Bura167 reputationPosted Dec 23, 2014, 2:49 AM EST
Here is link of program:
https://www.dropbox.com/s/vzzgpmzeez2dz4w/TMSDecryptionAPI%20v1.0%2010092012.rar?dl=0
If I don't know the names of input files in the directory.
VulpesRank #55 · 29.2K reputationPosted Dec 23, 2014, 3:22 AM EST
Although there's an easy way to iterate through all .txt files in a particular directory, before you do that, I'd create some specimen files - called input.txt and input1.txt - to check your encryption API is working OK.
Robin Bura167 reputationPosted Dec 23, 2014, 6:31 PM EST