By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,894 Members | 2,161 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,894 IT Pros & Developers. It's quick & easy.

Socket.SendFile( ) alt. in .net 1.1?

P: n/a
Hi all,
I'm using .NET 2.0 but unfortunately there's a windows service that
needs to be implemented in .NET 1.1 ... so I need to send a file to a
server, what's the similar method of doing so in 1.1?

Socket client = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);

client.Connect("127.0.0.1", 8000);

string fileName = "C:\\Folder\\file.xml";

client.SendFile(fileName);
client.Shutdown(SocketShutdown.Both);
client.Close();
TIA

Sep 25 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Well after some time on MSDN & books I managed to get this & add it to
my code (not tested yet) ... comments are welcome.

{
Int32 port = 8000;
private static string fileToUpload;
// get the file path from a config file (xml)
fileToUpload =
ConfigurationSettings.AppSettings.Get("CSV").ToStr ing();

Stream fileStream = File.OpenRead(fileToUpload);
// Alocate memory space for the file
byte[] fileBuffer = new byte[fileStream.Length];
fileStream.Read(fileBuffer, 0, (int)fileStream.Length);
// Open a TCP/IP Connection and send the data
TcpClient clientSocket=new TcpClient("127.0.0.1", port);
NetworkStream networkStream = clientSocket.GetStream();
networkStream.Write(fileBuffer,0,fileBuffer.GetLen gth(0));
networkStream.Close();
}
Aerodyne wrote:
Hi all,
I'm using .NET 2.0 but unfortunately there's a windows service that
needs to be implemented in .NET 1.1 ... so I need to send a file to a
server, what's the similar method of doing so in 1.1?

Socket client = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);

client.Connect("127.0.0.1", 8000);

string fileName = "C:\\Folder\\file.xml";

client.SendFile(fileName);
client.Shutdown(SocketShutdown.Both);
client.Close();
TIA
Sep 25 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.