0

How to create a file from a local computer directly onto a web server?

I tried but got this error:

URI format not supported.

My code is:

 string path = Server.MapPath("~/App_Data/");
 string path = "http://www.domainname.com/App_Data/";
 string jsondata = new JavaScriptSerializer().Serialize(enquirydet);
 System.IO.File.WriteAllText(path + "enq.json", jsondata);

Any way how I can do that?

waka
  • 3,362
  • 9
  • 35
  • 54
Shail
  • 29
  • 1
  • 8
  • Creating a file directly on web server is not that simple. Are you able to browse that folder of web server from local machine? Are you able to create file there directly without using your code? – Chetan Oct 10 '17 at 07:32
  • I can do it using ftp details, which I have. – Shail Oct 10 '17 at 07:35
  • then ftp the file – BugFinder Oct 10 '17 at 07:36
  • If the location is not publicly accessible then your code can't create file there just like that. – Chetan Oct 10 '17 at 07:39
  • In your code there is a syntax error. you can't create two variables with the same name like you have `path`. – mmushtaq Oct 10 '17 at 07:45
  • Yes variable one path is commented already. How should I upload file using ftp in asp.net c# – Shail Oct 10 '17 at 08:15
  • Possible duplicate of [Uploading Files in ASP.net without using the FileUpload server control](https://stackoverflow.com/questions/569565/uploading-files-in-asp-net-without-using-the-fileupload-server-control) – John Wu Oct 10 '17 at 09:22
  • what you trying can cause security problems, creating file/folder on remote server. Here is what i suggested, create a method that, accept your params and create on the file/folder on server side. – Yigit Yuksel Oct 12 '17 at 08:00

0 Answers0