Я загружаю PDF-файл с FTP-сервера. Мне нужно найти строку и заменить ее, но когда я пытаюсь преобразовать byte [] в строку. Возвращает бессмысленную строку.
WebClient client = new WebClient();
string url = "ftp://myftp.com/doc.pdf";
client.Credentials = new NetworkCredential("username", "password");
byte[] newFileData = client.DownloadData(url);
string s = System.Text.Encoding.UTF8.GetString(newFileData, 0, newFileData.Length);
// This return a odd string
// I would like to replace, for example, all the occurrences of #TEST# to "ABC"
MemoryStream pdfStream = new MemoryStream();
pdfStream.Write(newFileData, 0, newFileData.Length);
pdfStream.Position = 0;
return new FileStreamResult(pdfStream, "application/pdf");
Спасибо