using (FileStream fstream = File.OpenRead(dlg.FileName))
{
// преобразуем строку в байты
byte[] array = new byte[fstream.Length];
// считываем данные
fstream.Read(array, 0, array.Length);
// декодируем байты в строку
<b>content += Convert.ToBase64String(array);</b>
}
...
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL_F);
request.Method = "POST";
string jsonContent = "{\u0022branch\u0022:\u0022master\u0022, \u0022author_name\u0022:\u0022Sergey\u0022, \u0022content\u0022:\u0022" + content + "\u0022,\u0022commit_message\u0022:\u0022My commit\u0022}";
<i>System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
Byte[] byteArray = encoding.GetBytes(jsonContent);
request.ContentLength = byteArray.Length;
request.ContentType = @"application/json";
using (Stream dataStream = request.GetRequestStream())
{
dataStream.Write(byteArray, 0, byteArray.Length);
}</i>
long length = 0;
try
{
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
length = response.ContentLength;
}
}