1

I am trying to save the pdf file to the server. Locally on my computer, its worked fine but when I try to write to the server an error says "URI formats are not supported. " appear.

string filename = DateTime.Now.ToString("yyyy-M-dd--HH-mm-ss");
string reportFilesPath ="http://xxx.xx.xx.xx:xxxx/Files/";

streamBytes = rv.LocalReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);

File.WriteAllBytes(Path.Combine(reportFilesPath, filename + "test.pdf"), streamBytes);

the error happened when trying to execute this line

 File.WriteAllBytes(Path.Combine(reportFilesPath, filename + "test.pdf"), streamBytes);

please note that when i take the following path http://xxx.xx.xx.xx:xxxx/Files/filename.pdf

and past it to google i can see it.

Rand Random
  • 7,300
  • 10
  • 40
  • 88
Noor Allan
  • 421
  • 2
  • 7
  • 17
  • Have a look at: https://stackoverflow.com/questions/263518 – Rand Random Mar 03 '19 at 13:13
  • Or this: https://stackoverflow.com/questions/1131425/send-a-file-via-http-post-with-c-sharp – Rand Random Mar 03 '19 at 13:16
  • You can’t just use URIs to save files into. Most HTTP servers don’t have systems in place that would allow that (WebDAV for example) so you’ll have to store it as an actual file on the server somehow. – Sami Kuhmonen Mar 03 '19 at 13:22
  • @SamiKuhmonen I have "Files" folder exist in the server and I want to save created pdf file inside it. – Noor Allan Mar 04 '19 at 07:26
  • Then what is stopping you from writing it into that folder? – Sami Kuhmonen Mar 04 '19 at 07:36
  • You simply can't write a file into a `http` - thats not a file operation nativly supported by the OS, there are ways to do it like `WebDav` but thats something you have to enable and configure yourself for it to work. If you want to save a file on a `http` adress you will have to upload the file to your server - simples solution of my posted related questions is `using(WebClient client = new WebClient()) { client.UploadFile(address, filePath); }` – Rand Random Mar 04 '19 at 08:42

0 Answers0