hi
i got one file transfer program using serialization which has a limitation
that i can send only 8192 bytes(8KB). i want to send more than that wht can i
do. how can i divide the file into mutiple segment and send the file and
receive it. here is the program below
public static void SendFileInfo()
{
// Get file type or extension
fileDet.FILETYP E = fs.Name.Substri ng((int)fs.Name .Length - 3, 3);
// Get file length (Future purpose)
fileDet.FILESIZ E = fs.Length;
XmlSerializer fileSerializer = new XmlSerializer(t ypeof(FileDetai ls));
MemoryStream stream = new MemoryStream();
// Serialize object
fileSerializer. Serialize(strea m, fileDet);
// Stream to byte
stream.Position = 0;
byte[] bytes = new byte[stream.Length];
stream.Read(byt es, 0, Convert.ToInt32 (stream.Length) );
Console.WriteLi ne("Sending file details...");
// Send file details
sender.Send(byt es, bytes.Length, endPoint);
stream.Close();
}
and in the receiving end
public static void ReceiveFile()
{
try
{
Console.WriteLi ne(
"-----------*******Waiting to get File!!*******-----------");
// Receive file
receiveBytes = receivingUdpCli ent.Receive(ref RemoteIpEndPoin t);
// Convert and display data
Console.WriteLi ne("----File received...Savi ng...");
// Create temp file from received file extension
fs = new FileStream("tem p." + fileDet.FILETYP E, FileMode.Create ,
FileAccess.Read Write, FileShare.ReadW rite);
fs.Write(receiv eBytes, 0, receiveBytes.Le ngth);
Console.WriteLi ne("----File Saved...");
Console.WriteLi ne("-------Opening file with associated program------");
Process.Start(f s.Name); // Opens file with associated program
}
catch (Exception e)
{
Console.WriteLi ne(e.ToString ());
}
finally
{
//fs.Close();
receivingUdpCli ent.Close();
}
}
plz give solution for this
thanks for advance
lkr
i got one file transfer program using serialization which has a limitation
that i can send only 8192 bytes(8KB). i want to send more than that wht can i
do. how can i divide the file into mutiple segment and send the file and
receive it. here is the program below
public static void SendFileInfo()
{
// Get file type or extension
fileDet.FILETYP E = fs.Name.Substri ng((int)fs.Name .Length - 3, 3);
// Get file length (Future purpose)
fileDet.FILESIZ E = fs.Length;
XmlSerializer fileSerializer = new XmlSerializer(t ypeof(FileDetai ls));
MemoryStream stream = new MemoryStream();
// Serialize object
fileSerializer. Serialize(strea m, fileDet);
// Stream to byte
stream.Position = 0;
byte[] bytes = new byte[stream.Length];
stream.Read(byt es, 0, Convert.ToInt32 (stream.Length) );
Console.WriteLi ne("Sending file details...");
// Send file details
sender.Send(byt es, bytes.Length, endPoint);
stream.Close();
}
and in the receiving end
public static void ReceiveFile()
{
try
{
Console.WriteLi ne(
"-----------*******Waiting to get File!!*******-----------");
// Receive file
receiveBytes = receivingUdpCli ent.Receive(ref RemoteIpEndPoin t);
// Convert and display data
Console.WriteLi ne("----File received...Savi ng...");
// Create temp file from received file extension
fs = new FileStream("tem p." + fileDet.FILETYP E, FileMode.Create ,
FileAccess.Read Write, FileShare.ReadW rite);
fs.Write(receiv eBytes, 0, receiveBytes.Le ngth);
Console.WriteLi ne("----File Saved...");
Console.WriteLi ne("-------Opening file with associated program------");
Process.Start(f s.Name); // Opens file with associated program
}
catch (Exception e)
{
Console.WriteLi ne(e.ToString ());
}
finally
{
//fs.Close();
receivingUdpCli ent.Close();
}
}
plz give solution for this
thanks for advance
lkr
Comment