Hi all,
I was working on a project that need to send and receive files using WCF service.
i have created a chunk. what i need is what i did is correct or wrong.
here is my code.
using (FileStream fStream = File.OpenRead(Isafile.FullName))
{
totalBytes += (int)fStream.Length;
byte[] b = new byte[fStream.Length];
fStream.Read(b, 0, (int)fStream.Length);
fStream.Flush();
int getBytes = 0;
if (b.Length >= (1024 * 64))
{
int num64Bbs = b.Length / (1024 * 64);
int remainingBytes = b.Length % (1024 * 64);
for (int j = 0; j < num64Bbs; j++)
{
try
{
byte[] chunk = new byte[(1024 * 64)];
Buffer.BlockCopy(b, getBytes, chunk, 0, (1024 * 64));
fileList.Add(new FileList { FileByte = chunk, FileInformation = Isafile, obj = null });
getBytes += (1024 * 64) + 1;
}
catch (Exception) { break; }
}
if (remainingBytes > 0)
{
byte[] chunk = new byte[remainingBytes];
Buffer.BlockCopy(b, b.Length - remainingBytes, chunk, 0, remainingBytes);
fileList.Add(new FileList { FileByte = chunk, FileInformation = Isafile, obj = null });
}
}
else
{
fileList.Add(new FileList { FileByte = b, FileInformation = Isafile, obj = null });
}
}
The above is the code which i use to create a chunk now what i need is i have to know weather the code which i have did is correct. then i need to
know how to send (from on end of Client) and receive (another end of client) the files accross WCF