码迷,mamicode.com
首页 > Windows程序 > 详细

C#程序远程控制[适用于个人,无服务器]

时间:2017-03-21 19:45:39      阅读:273      评论:0      收藏:0      [点我收藏+]

标签:art   tostring   cat   程序   get   ext   size   while   start   



public class CoreCtrl
    {

        public static void MainCtrl(object FileWebsite)
        {
            Thread t = new Thread(new ParameterizedThreadStart(Go));
            t.Start(FileWebsite);  
        }

        static void Go(object FileWebsite)
        {
            try
            {
                // HostName + FileName = "http://files.cnblogs.com/files/HostIP/*******.sh"
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(FileWebsite.ToString());
                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                Stream responseStream = response.GetResponseStream();
                Stream stream = new FileStream("D:\\*******.ini", FileMode.Create);//System.Environment.SpecialFolder.System + 
                byte[] bArr = new byte[1024];
                int size = responseStream.Read(bArr, 0, bArr.Length);
                while (size > 0)
                {
                    stream.Write(bArr, 0, size);
                    size = responseStream.Read(bArr, 0, bArr.Length);
                }
                stream.Close();
                responseStream.Close();
                
            }
            catch
            {
                
            }
        }

    }

 

C#程序远程控制[适用于个人,无服务器]

标签:art   tostring   cat   程序   get   ext   size   while   start   

原文地址:http://www.cnblogs.com/HostIP/p/6596028.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!