please any one convert this code from c++ to c# beacuse i dont know how to read from file in c++ please help me
int DoEnDe(int c)
{
SDES S(key);
int i,n;
n=10; //Number of Rounds
unsigned char ch;
FILE *fp;
FILE *ft;
fp=fopen(tfname,"w");
ft=fopen(sfname,"r");
if (fp==NULL)
{
printf("\nTarget File not opened SORRY");
getch();
fclose(fp);
return(0);
}
if (ft==NULL)
{
printf("\nSource File not opened SORRY");
getch();
fclose(ft);
return(0);
}
while (fread(&ch,1,1,ft)==1)
{
S.OUTPUT=ch;
for (i=0;i<n;i++)
{
if (c==1)
S.DES_Encryption(S.OUTPUT);
if (c==2)
S.DES_Decryption(S.OUTPUT);
}
fwrite(&S.OUTPUT,1,1,fp);
}
printf("\nCompleted!!!!!");
getch();
fclose(fp);
fclose(ft);
return(1);
}