Click here to Skip to main content
15,893,790 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends,
I am using "CryptoStream" to read data from my encrypted file. If this file is empty it raises an exception. Now i want to check whether my file is empty or not.
Plz tell me the way.
Posted
Updated 22-May-10 0:32am
v2

Hi friend.
you can use System.IO namespace to provide filing functionality. to check the availability of file you must go as under
<br />
if(File.Exist("File path"))<br />
{<br />
//perform encryption function here in<br />
}<br />
 
Share this answer
 
Comments
darora85 22-May-10 7:07am    
thanks buddy.
J imran 22-May-10 9:04am    
no problem...:)
William Winner 22-May-10 17:26pm    
Reason for my vote of 2
while he marked it as an answer, it actually doesn't answer his question, which said if the file is empty. The language implies that the file exists, but has nothing in it. If that is the case in which the exception is being thrown, then this answer will not solve that problem.
Looking at the msdn sample here, I noticed that they check if while(rdlen < totlen) as a while condition.

You have not provided any code here, so I cannot be sure - but I guess a condition like this should be sufficient to avoid null errors? You can always directly check if an object is null by doing an if condidition check against it.
 
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