I
I
Ivan Vyrov2016-07-27 07:54:40
C++ / C#
Ivan Vyrov, 2016-07-27 07:54:40

An error occurs while working, where is it?

There is WCF which accepts files and saves on the server.
Client code:

if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                #region Загрузка и перевод файла
                FileStream fs = new FileStream(@openFileDialog1.FileName, FileMode.Open);
                byte[] buffer = new byte[fs.Length];
                int len = (int)fs.Length;
                fs.Read(buffer, 0, len);
                //string st = string.Empty;
                //for (int i = 0; i < buffer.Length; i++)
                //{
                //    st += buffer[i].ToString() + ", ";
                //}
                //textBox1.Text = st;
                //byte[] buffer = { 37, 80, 68, 70, 45, 49, 46, 52, 10, 37, 226, 227, 207, 211, 10, 49, 32, 48, 32, 111, 98, 106, 10, 60, 60, 10, 47, 84, 121 };
                fs.Close();
                #endregion
                client.Load("Тест", 15, "Тестовый_файл.rtf", 60, buffer); //Обращаемся к WCF
            }

The question is: why does WCF throw a timeout exception - only when the buffer fills up automatically.
If the buffer is filled in manually, then everything is OK, where to look for the error?
filling the buffer manually (excerpt from the array in the original 56Kb, the size does not matter because files up to 200Mb were transferred manually):
byte[] buffer = { 37, 80, 68, 70, 45, 49, 46, 52, 10, 37, 226, 227, 207, 211, 10, 49, 32, 48, 32, 111, 98, 106, 10, 60, 60, 10, 47, 84, 121 };

Answer the question

In order to leave comments, you need to log in

1 answer(s)
#
#algooptimize #bottize, 2016-07-27
@user004

Reading a file takes time, s += is not optimal, takes time, check this time.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question