클래스 라이브러리를 웹에서 다운 받은 후 동적로딩하면 더 좋지 않을까? 란 생각에 다운로드받는 부분도 찾아봤다..

        private void Download(string strModule)
        {
            try {
                WebRequest ttt = WebRequest.Create("http://indra17.mireene.com/Test/" + strModule + ".dll");
                WebResponse mmm = ttt.GetResponse();
                Stream kkk = mmm.GetResponseStream();

                int BUFFER = 1024;
                BinaryWriter bw = null;
                BinaryReader br = new BinaryReader(kkk);
                try
                {
                    Byte[] data = new byte[BUFFER];
                    FileStream fs = new FileStream(System.IO.Path.Combine(m_strSavePath, strModule + ".dll"), FileMode.Create);

                    long total = 0;
                    int recv_size = 0;

                    long prg_value = 0;
                    long time = 0;

                    try
                    {
                        bw = new BinaryWriter(fs);

                        while (true)
                        {
                            recv_size = br.Read(data, 0, BUFFER);

                            if (recv_size <= 0) break;

                            bw.Write(data, 0, recv_size);

                            total += recv_size;
                        }
                        Console.WriteLine("Download Size = {0}", total);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                    finally
                    {
                        if (bw != null) bw.Close();
                        if (br != null) br.Close();
                    }
                    fs.Close();

                    kkk.Close();
                    mmm.Close();
                } catch (ArgumentNullException ane) {
                    Console.WriteLine("ArgumentNullException : {0}",ane.ToString());
                } catch (SocketException se) {
                    Console.WriteLine("SocketException : {0}",se.ToString());
                } catch (Exception e) {
                    Console.WriteLine("Unexpected exception : {0}", e.ToString());
                }
            } catch (Exception e) {
                Console.WriteLine( e.ToString());
            }
       }

'develop > windows' 카테고리의 다른 글

MHTML 저장 유의사항  (0) 2011.03.09
C#에서 클래스 라이브러리 동적 로딩  (0) 2010.09.29
C# ActiveX 만들기  (0) 2010.09.29
ActiveX 에서 다른 ActiveX를 생성할 때 주의점  (0) 2010.07.29
IObjectSafety  (1) 2010.02.03

+ Recent posts