Filed under C#
//IDownloadHandler 의 구현체를 만들어서  DownloadHandler 를 등록 해주면된다.
// 아래소스는 updated에서 다운로드되는 상황을 체크 할 수 있으며
// downloadItem.IsComplete 다운로드가 완료되었을 때 파일을 실행하도록 구현함
// 상황에 따라서 확장자에 맞게 처리 하면됨.

 chromebrowser.DownloadHandler = new DownloadHandler();
internal class DownloadHandler : IDownloadHandler
        public object OnDownloadUpdatedFired { get; private set; }
        public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
            if (!callback.IsDisposed) {
                using (callback) {
                    callback.Continue(@"C:\Users\" +
                             System.Security.Principal.WindowsIdentity.GetCurrent().Name +
                             @"\Downloads\" +
                         showDialog: true);
        public void OnDownloadUpdated(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback)
            if (downloadItem.IsComplete)
                if (@downloadItem.FullPath != "")
2020/04/13 15:18 2020/04/13 15:18
Filed under C#
c#  add mediaplayer component
Tool Box Items->Com Components->Windows Media Player

player.URL="재생 주소";
주소만 할당해주면 재생됨
2018/07/03 18:37 2018/07/03 18:37
Filed under C#

using System;

class Program {
    static void Main(string[] args) {
        System.AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionTrapper;
        throw new Exception("Kaboom");

    static void UnhandledExceptionTrapper(object sender, UnhandledExceptionEventArgs e) {
        Console.WriteLine("Press Enter to continue");

// c#에서 Console(콘솔) 어플리케이션에서 글로벌 에러 처리
   반복 작업시 유용하게 이용



2016/10/13 09:14 2016/10/13 09:14
Filed under C#


public static void SaveJpeg(string path, Image img, int quality)
            if (quality < 0 || quality > 100)
                throw new ArgumentOutOfRangeException("quality must be between 0 and 100.");

            // Encoder parameter for image quality
            EncoderParameter qualityParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality);
            // JPEG image codec
            ImageCodecInfo jpegCodec = GetEncoderInfo("image/jpeg");
            EncoderParameters encoderParams = new EncoderParameters(1);
            encoderParams.Param[0] = qualityParam;
            img.Save(path, jpegCodec, encoderParams);

        /// <summary>
        /// Returns the image codec with the given mime type
        /// </summary>
        private static ImageCodecInfo GetEncoderInfo(string mimeType)
            // Get image codecs for all image formats
            ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();

            // Find the correct image codec
            for (int i = 0; i < codecs.Length; i++)
                if (codecs[i].MimeType == mimeType)
                    return codecs[i];

            return null;

2016/03/04 10:58 2016/03/04 10:58
Filed under C#


a =(int)Convert.ToDouble("1.2");

Note if you're using comma as a number separator in your operating system, you have to use IFormatProvider:

var a =(int)Convert.ToDouble("1.2",CultureInfo.InvariantCulture.NumberFormat);

Another way to accomplish this task:

var a =int.Parse("1.2".Split('.')[0]);

2016/02/12 18:38 2016/02/12 18:38
Filed under C#
I found this solution to work for me when trying to access a file share on another computer.  It basically simulates doing a NET USE command where you can specify the credentials to use on the remote end.  The nice part is that you do not have to impersonate the user and it works across domains and workgroup computers.

First, declare these functions and types in your class.

using System.Reflection;
using System.Runtime.InteropServices;
using System.ComponentModel;

public class YourClass {
private static extern int WNetAddConnection2A(ref NetResource pstNetRes, string psPassword, string psUsername, int piFlags);
private static extern int WNetCancelConnection2A(string psName, int piFlags, int pfForce);

private struct NetResource {
    public int iScope;
    public int iType;
    public int iDisplayType;
    public int iUsage;
    public string sLocalName;
    public string sRemoteName;
    public string sComment;
    public string sProvider;

private const int RESOURCETYPE_DISK = 0x1;

Then, add these two methods.
    private void LoginToShare(string serverName, string shareName, string user, string password) {
        string destinationDirectory = string.Format(@"\\{0}\{1}", serverName, shareName);

        NetResource nr = new NetResource();
        nr.iScope = 2;
        nr.iType = RESOURCETYPE_DISK;
        nr.iDisplayType = 3;
        nr.iUsage = 1;
        nr.sRemoteName = destinationDirectory;
        nr.sLocalName = null;

        int flags = 0;
        int rc = WNetAddConnection2A(ref nr, password, user, flags);

        if (rc != 0) throw new Win32Exception(rc);

    private void LogoutFromShare(string serverName, string shareName) {
        string destinationDirectory = string.Format(@"\\{0}\{1}", serverName, shareName);
        int flags = 0;
        int rc = WNetCancelConnection2A(destinationDirectory, flags, Convert.ToInt32(false));

In your code, call the LoginToShare with the server, share, user, and password needed.  Then simply use the standard \\server\share\path conventions for accessing files on remote computers.  Call the LogoutFromShare when you're done.

2016/01/26 10:05 2016/01/26 10:05
Filed under C#
private void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e){
       if (e.Url.AbsoluteUri == wb.Url.AbsoluteUri) {


ajax 용 웹페이지 파싱할 때위처럼 구현하면 여러번 사이트 로딩 되는 현상을 방지 할 수 있다.
2015/07/18 00:48 2015/07/18 00:48
Filed under C#

[참고] :

[wcp 개발시  즉 namespace 변경하기]

[ServiceContract(Namespace="")] 선언

[ServiceBehavior(Namespace="")] 선언


<?xml version="1.0" encoding="utf-8"?>

    <compilation debug="true" targetFramework="4.0" />
      <service name="billing.service">
        <endpoint address=""
        binding ="basicHttpBinding"
          <!-- 메타데이터 정보를 공개하지 않으려면 배포하기 전에 아래의 값을 false로 설정하고 위의 메타데이터 끝점을 제거하십시오. -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- 디버깅 목적으로 오류에서 예외 정보를 받으려면 아래의 값을 true로 설정하십시오. 예외 정보를 공개하지 않으려면 배포하기 전에 false로 설정하십시오. -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <modules runAllManagedModulesForAllRequests="true"/>

2013/09/25 17:49 2013/09/25 17:49
Filed under C#
public partial class Form1 : Form
    public Form1()

    private void Form1_Load(object sender, EventArgs e)
        string[] data = { "사과", "토마토", "포도", "배", "복숭아" };

        // 각 콤보박스에 데이타를 초기화

        // 처음 선택값 지정. 첫째 아이템 선택
        comboSimple.SelectedIndex = 0;
        comboDropDown.SelectedIndex = 0;
        comboDropDownList.SelectedIndex = 0;
2013/05/30 09:06 2013/05/30 09:06
Filed under C#
api 리버싱 관련 하여 자료를 정리해놓은 좋은 불로그가 있어 링크 걸어 봅니다.
리버싱을 시작 하시는 분들에게는 좋은 정보가 될거 같내요.

리버싱의 원리 바로가기
2013/05/14 21:22 2013/05/14 21:22