I have a Server Application who EXEC another app, that second app builds a log file, and I want the server to send it to a client via WCF.
I want the client to read the log while the EXEC app update it.
I've used an operation contract that returns stream (the log file). the problem is that when I first send the stream, the log is still empty, and the client don't see the "update" that the server EXEC writes.
here is the server code:
public Stream GetLog()
{
Stream stream = new FileStream(@"Log.txt", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
return stream;
}
the EXEC from the server is simply writing to the "Log.txt" file
here is the client code:
public void SaveLog()
{
Stream stream = ServerProxy.GetLog();
StreamWriter writer = new StreamWriter("NEWLog.txt");
writer.AutoFlush = true;
StreamReader reader = new StreamReader(stream);
char[] buf = new char[100];
int count = 0;
while (count = reader.ReadBlock(buf, 0, 100) > 0)
{
writer.Write(buf, 0, count);
}
stream.Close();
writer.Close();
}
how can I update the Client with the Log in REAL-TIME?