+ Reply to Thread
Results 1 to 2 of 2

Thread: Excute php scripts on webserver

  1. #1

    Question Excute php scripts on webserver

    I was wondering how can i execute a PHP Script on a webserver using C# ?
    Last edited by csharpmaster; 11-01-2012 at 02:59 PM.

  2. #2
    Junior Member
    Join Date
    Jan 2012
    So assume you have got a php or any kind of script that once is visited on a web browser it does something.
    So what will we do is just creating a HTTPWebRequest to excute the script.

    Example : you will call a php script that will unzip a file on server , here is how it will be called.
            private void Run_Unzip()
                HttpWebRequest httpwr = (HttpWebRequest)WebRequest.Create("http://www.website.com/extract.php");
                HttpWebResponse response = (HttpWebResponse)httpwr.GetResponse();
                StreamReader sr = new StreamReader(response.GetResponseStream());
                // the echo result provided by the php script
                string final_Res = sr.ReadToEnd();
                if (final_Res.Contains("ok"))
                    MessageBox.Show("Files Extracted without problem");
    		// show any error message here
    So simply when you call the extract.php and it sucessfully extracted files , it will echo ok on the webpage , so the application
    will read the source code of the page and if there is "ok" then our method worked right.

+ Reply to Thread

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts