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");
}
}
}
Robin BuraPosted Dec 23, 2014, 11:31 PM
VulpesPosted Dec 23, 2014, 8:22 AM
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 BuraPosted Dec 23, 2014, 7:49 AM
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.
VulpesPosted Dec 23, 2014, 7:37 AM
Robin BuraPosted Dec 23, 2014, 7:24 AM
VulpesPosted Dec 23, 2014, 7:16 AM
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 BuraPosted Dec 23, 2014, 7:07 AM
VulpesPosted Dec 23, 2014, 6:53 AM
Robin BuraPosted Dec 23, 2014, 6:12 AM
Input files are many from a directory and output should be one.
Here is code i designed for two input files
VulpesPosted Dec 23, 2014, 5:52 AM
If this takes too long or makes the UI unresponsive, then you may need to consider using background threads to spread the load.