Skip to content

Commit 35bafb5

Browse files
committed
Subfolder bug patch
1 parent 35c1cbc commit 35bafb5

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

FileSecure-v3/Program.cs

+12-4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static void Encrypt(string Password,string OpenPath, string SavePath)
3737
CipherStream cryptstream = new CipherStream(plainfile, buffblockcipher, buffblockcipher);
3838
try
3939
{
40+
Console.WriteLine("The File (" + OpenPath + ") has been queued for encryption");
4041
cryptstream.CopyTo(encryptfile);
4142
Console.WriteLine("The File (" + OpenPath + ") has been successfully encrypted");
4243
} catch (UnauthorizedAccessException)
@@ -68,6 +69,7 @@ static public void Decrypt(string Password, string OpenPath, string SavePath)
6869
buffblockcipher.Init(false, new AeadParameters(new KeyParameter(PasswordToKey), 128, nonce));
6970
try
7071
{
72+
Console.WriteLine("The File (" + OpenPath + ") has been queued for decryption");
7173
cryptstream.CopyTo(plainfile);
7274
Console.WriteLine("The File ("+OpenPath+") has been successfully decrypted.");
7375
} catch (UnauthorizedAccessException)
@@ -235,15 +237,18 @@ static void Main(string[] args)
235237
// Encrypting mass file
236238
string[] Files = Directory.GetFiles(OpenPath);
237239
int TotalProcessedFile = 0;
240+
int TotalFileAvaible = 0;
238241
Console.WriteLine("Mass File Encryption Started...");
239242
foreach(string file in Files)
240243
{
241-
Task.Run(() => { Encrypt(Password, file, SavePath + "/" + Path.GetFileName(file)); TotalProcessedFile = TotalProcessedFile + 1; if (TotalProcessedFile >= Files.Length) { Console.WriteLine("Mass File Encryption Process completed, press enter to exit."); }});
244+
if (Path.GetFileName(file) != "")
245+
TotalFileAvaible = TotalFileAvaible + 1;
246+
Task.Run(() => { Encrypt(Password, file, SavePath + "/" + Path.GetFileNameWithoutExtension(file)+Path.GetExtension(file)); TotalProcessedFile = TotalProcessedFile + 1; if (TotalProcessedFile >= Files.Length) { Console.WriteLine("Mass File Encryption Process completed, press enter to exit."); }});
242247
}
243248
while(true)
244249
{
245250
Console.ReadLine();
246-
if(TotalProcessedFile >= Files.Length)
251+
if(TotalProcessedFile >= TotalFileAvaible)
247252
{
248253
break;
249254
}
@@ -253,15 +258,18 @@ static void Main(string[] args)
253258
// Decrypting mass file
254259
string[] Files = Directory.GetFiles(OpenPath);
255260
int TotalProcessedFile = 0;
261+
int TotalFileAvaible = 0;
256262
Console.WriteLine("Mass File Decryption Started...");
257263
foreach (string file in Files)
258264
{
259-
Task.Run(() => { Decrypt(Password, file, SavePath+"/"+Path.GetFileName(file)); TotalProcessedFile = TotalProcessedFile + 1; if (TotalProcessedFile >= Files.Length) { Console.WriteLine("Mass File Decryption Process completed, press enter to exit."); } });
265+
if (Path.GetFileName(file) != "")
266+
TotalFileAvaible = TotalFileAvaible + 1;
267+
Task.Run(() => { Decrypt(Password, file, SavePath+"/"+ Path.GetFileNameWithoutExtension(file) + Path.GetExtension(file)); TotalProcessedFile = TotalProcessedFile + 1; if (TotalProcessedFile >= Files.Length) { Console.WriteLine("Mass File Decryption Process completed, press enter to exit."); } });
260268
}
261269
while (true)
262270
{
263271
Console.ReadLine();
264-
if (TotalProcessedFile >= Files.Length)
272+
if (TotalProcessedFile >= TotalFileAvaible)
265273
{
266274
break;
267275
}

0 commit comments

Comments
 (0)