S
shahla.saeed
hi,
plzz check my code and let me know where the problem is
lying...becuase whenever i try to tansfer the file of 573KB(mp3) it
just tranfer few Kb of file(Somtimes 5.2Kb,somtimes 32Kb..every time i
run the program).....but when i watch the transfering of bytes by
debuging it.(RED dot on while(nfs.CanRead) )..it shows that complete
bytes are transfered.(in my case i-e 573Kb)....i am unable to
understand whats going wrong in my program.
same is the problem with text file..it reads the bytes but not write
on file...
*CODE at RECIEVING END*
byte[] buffed = new byte[6000] ;
string Fname=System.Text.Encoding.ASCII.GetString(f_name,
0,count_char);
string pth=@"C:\Documents and Settings\Administrator\My Documents
\shared1\ ";
FileStream fout = new FileStream(pth+Fname, FileMode.Create,
FileAccess.Write) ;
NetworkStream nfs = new NetworkStream(Dsock) ;
string myCompleteMessage = "";
int numberOfBytesRead = 0;
while(nfs.CanRead)
{
if(nfs.DataAvailable)
{
numberOfBytesRead = nfs.Read(buffer, 0, buffer.Length);
myCompleteMessage =
string.Concat(System.Text.Encoding.ASCII.GetString (buffer, 0,
numberOfBytesRead));
fout.Write(buffer,0,(int)numberOfBytesRead) ;
}
}
*CODE at SENDING END*
int len=0;
byte[] buffed = new byte[6000] ;
//Open the file requested for download
FileStream fin = new FileStream(loadfile,FileMode.Open ,
FileAccess.Read) ;
//One way of transfer over sockets is Using a NetworkStream
NetworkStream nfs = new NetworkStream(DlSck_Arr[0]);
while(nfs.CanWrite)
{
//Read from the File (len contains the number of bytes read)
len =fin.Read(buffed,0,buffed.Length) ;
//Write the Bytes on the Socket
nfs.Write(buffed, 0,len);
//Increase the bytes Read counter
}
len=len+0;
}
plzz check my code and let me know where the problem is
lying...becuase whenever i try to tansfer the file of 573KB(mp3) it
just tranfer few Kb of file(Somtimes 5.2Kb,somtimes 32Kb..every time i
run the program).....but when i watch the transfering of bytes by
debuging it.(RED dot on while(nfs.CanRead) )..it shows that complete
bytes are transfered.(in my case i-e 573Kb)....i am unable to
understand whats going wrong in my program.
same is the problem with text file..it reads the bytes but not write
on file...
*CODE at RECIEVING END*
byte[] buffed = new byte[6000] ;
string Fname=System.Text.Encoding.ASCII.GetString(f_name,
0,count_char);
string pth=@"C:\Documents and Settings\Administrator\My Documents
\shared1\ ";
FileStream fout = new FileStream(pth+Fname, FileMode.Create,
FileAccess.Write) ;
NetworkStream nfs = new NetworkStream(Dsock) ;
string myCompleteMessage = "";
int numberOfBytesRead = 0;
while(nfs.CanRead)
{
if(nfs.DataAvailable)
{
numberOfBytesRead = nfs.Read(buffer, 0, buffer.Length);
myCompleteMessage =
string.Concat(System.Text.Encoding.ASCII.GetString (buffer, 0,
numberOfBytesRead));
fout.Write(buffer,0,(int)numberOfBytesRead) ;
}
}
*CODE at SENDING END*
int len=0;
byte[] buffed = new byte[6000] ;
//Open the file requested for download
FileStream fin = new FileStream(loadfile,FileMode.Open ,
FileAccess.Read) ;
//One way of transfer over sockets is Using a NetworkStream
NetworkStream nfs = new NetworkStream(DlSck_Arr[0]);
while(nfs.CanWrite)
{
//Read from the File (len contains the number of bytes read)
len =fin.Read(buffed,0,buffed.Length) ;
//Write the Bytes on the Socket
nfs.Write(buffed, 0,len);
//Increase the bytes Read counter
}
len=len+0;
}