Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
/I hvae written below code for encryption and i am trying to decrypt the file using client.upload but i am unable to do the same.please suggest

What I have tried:

IEnumerable<string> files = Directory.EnumerateFiles(@"E:\\Folder1");
			using (WebClient client = new WebClient())
			{
			 client.Credentials = new NetworkCredential("username", "password");
			 	//encrypr datetime.
			 	upload_encryption.AES a = new AES();
			 foreach (string file in files)
		     {	         
				 	FileInfo file1=new FileInfo(file);				 	
				 	a.EncryptFile(file.ToString(),"D:\\test"+file1.Extension,"passwd");
				 	client.UploadFile("ftp://192." + Path.GetFileName(file), "D:\\test"+file1.Extension);	
		           File.Delete("D:\\test"+file1.Extension);
		            FileInfo file2= new FileInfo(file);
		            a.DecryptFile("ftp://192..... ","D:\\test"+file2.Extension,"passwd");
		            client.DownloadFile("ftp://192./"+Path.GetFileName(file),"D:\\test"+file2.Extension);
					//File.Delete("D:\\test"+file2.Extension);		            
	         }
		    }        	 
       	}
        	catch(Exception e)
        	{
        		
        	}
Posted
Updated 9-May-18 2:23am
Comments
Ravi Bhavnani 9-May-18 9:48am    
BTW, @"E:\\Folder1" is not a valid directory name.

/ravi

1 solution

Start by doing two things:
1) Check your password.
2) Encrypt the file using your existing code, and save it locally. Then use the code above to decrypt it locally, and compare the results. If they match, you need to look at the FTP process and if you are fetching the right file, that is hasn't been corrupted in transfer, or when you stored it, and so forth. If they don't, then you need to look at your encryption and decryption code to find the problem.

Sorry, but we can't do any of that for you!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900