Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How can create a directory on server where client is c#
Posted
Comments
Philippe Mori 16-May-15 8:48am    
This question does not make much sense...

You cannot, except if you ask the user to download and run the application.

If you could run a C# app client-side without confirmation, this would be a major security risk for the users of a website.
 
Share this answer
 
v2
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace createdirectory
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                string url = "http://##############/####.php";
                string str = "DirectoryaName"; ;
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
                req.Method = "POST";
                string Data = "message=" + str;
                byte[] postBytes = Encoding.ASCII.GetBytes(Data);
                req.ContentType = "application/x-www-form-urlencoded";
                req.ContentLength = postBytes.Length;
                Stream requestStream = req.GetRequestStream();
                requestStream.Write(postBytes, 0, postBytes.Length);
                requestStream.Close();
                HttpWebResponse response = (HttpWebResponse)req.GetResponse();
                Stream resStream = response.GetResponseStream();
                var sr = new StreamReader(response.GetResponseStream());
                string responseText = sr.ReadToEnd();


            }
            catch (WebException)
            {

                MessageBox.Show("Please Check Your Internet Connection");
            }
           
          
   
}
        }
    }
//and this is your php code to create directory 
on php server


<?php 
    if (isset($_POST['message']))
    {
        $msg = $_POST['message'];        
        mkdir($msg);}
   ?>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900