Exemple #1
0
 /// <summary>
 /// 서버의 파일 이름을 변경함.
 /// </summary>
 /// <param name="sExisting">원래 이름</param>
 /// <param name="sNewName">새 이름</param>
 public void RenameFile(string sExisting, string sNewName)
 {
     if (!FtpRenameFile(hConnection, sExisting, sNewName))
     {
         throw new Exception(CUtil.GetLastWin32ErrorInfo());
     }
 }
Exemple #2
0
 /// <summary>
 /// 서버에 있는 폴더를 삭제함.
 /// </summary>
 /// <param name="sDirectory">삭제할 폴더 이름</param>
 public void RemoveDirectory(string sDirectory)
 {
     if (!FtpRemoveDirectory(hConnection, sDirectory))
     {
         throw new Exception(CUtil.GetLastWin32ErrorInfo());
     }
 }
Exemple #3
0
 /// <summary>
 /// 서버의 파일을 삭제함.
 /// </summary>
 /// <param name="sRemote">삭제할 파일이 있는 서버의 경로</param>
 public void DeleteFile(string sRemote)
 {
     if (!FtpDeleteFile(hConnection, sRemote))
     {
         throw new Exception(CUtil.GetLastWin32ErrorInfo());
     }
 }
Exemple #4
0
 /// <summary>
 /// 파일을 업로드함.
 /// </summary>
 /// <param name="sLocal">업로드할 파일의 경로</param>
 /// <param name="sRemote">업로드될 서버의 경로</param>
 public void PutFile(string sLocal, string sRemote)
 {
     if (!FtpPutFile(hConnection, sLocal, sRemote, mTransferMode, 0))
     {
         throw new Exception(CUtil.GetLastWin32ErrorInfo());
     }
 }
Exemple #5
0
 /// <summary>
 /// FTP 서버의 파일을 다운 받음.
 /// </summary>
 /// <param name="sLocal">다운 받을 경로</param>
 /// <param name="sRemote">가져올 서버의 경로</param>
 public void GetFile(string sLocal, string sRemote)
 {
     //Local caching을 막으려면 dwFlags에 INTERNET_FLAG_NO_CACHE_WRITE(0x04000000)를 추가할 것.
     if (!FtpGetFile(hConnection, sRemote, sLocal, false, FILE_ATTRIBUTE_NORMAL, mTransferMode + INTERNET_FLAG_RELOAD, 0))
     {
         throw new Exception(CUtil.GetLastWin32ErrorInfo());
     }
 }
Exemple #6
0
        /// <summary>
        /// 생성자
        /// </summary>
        /// <param name="IsPassive">Passive 모드를 설정할 지 여부</param>
        public CFtp(bool IsPassive)
        {
            hOpen = InternetOpen("FTP Client", INTERNET_OPEN_TYPE_PRECONFIG, "", "", 0);
            if (hOpen == 0)
            {
                throw new Exception(CUtil.GetLastWin32ErrorInfo());
            }

            mTransferMode   = FTP_TRANSFER_TYPE_ASCII;
            mConnectionMode = IsPassive ? INTERNET_FLAG_PASSIVE : INTERNET_FLAG_ACTIVE;
            hConnection     = 0;
        }
Exemple #7
0
        /// <summary>
        /// FTP 서버에 연결함.
        /// </summary>
        /// <param name="sServer">서버 주소</param>
        /// <param name="Port">FTP 포트</param>
        /// <param name="sUser">아이디</param>
        /// <param name="sPassword">패스워드</param>
        public void Connect(string sServer, int Port, string sUser, string sPassword)
        {
            if (hConnection != 0)
            {
                InternetCloseHandle(hConnection);
            }

            if (Port == 0)
            {
                Port = CConst.Port21Ftp;
            }

            hConnection = InternetConnect(hOpen, sServer, Port, sUser, sPassword, INTERNET_SERVICE_FTP, mConnectionMode, 0);
            if (hConnection == 0)
            {
                throw new Exception(CUtil.GetLastWin32ErrorInfo());
            }
        }
Exemple #8
0
        private static void RegComponentByApi(string FileName, bool IsRegister)
        {
            //2011-06-07 등록 안되는 Windows 7 컴퓨터 있어 주석.
            int nLib = LoadLibraryA(FileName);

            if (nLib == 0)
            {
                throw new Exception(CUtil.GetLastWin32ErrorInfo());
            }

            string ProcName     = IsRegister ? "DllRegisterServer" : "DllUnregisterServer";
            int    nProcAddress = GetProcAddress(nLib, ProcName);

            if (nProcAddress == 0)
            {
                FreeLibrary(nLib);
                throw new Exception(CUtil.GetLastWin32ErrorInfo());
            }

            int hThread = CreateThread(0, 0, nProcAddress, 0, 0, 0);

            if (hThread == 0)
            {
                FreeLibrary(nLib);
                throw new Exception(CUtil.GetLastWin32ErrorInfo());
            }

            bool Success = (WaitForSingleObject(hThread, 10000) == WAIT_OBJECT_0);

            if (!Success)
            {
                int dwExitCode = 0;
                GetExitCodeThread(hThread, dwExitCode);
                ExitThread(dwExitCode);
                FreeLibrary(nLib);
                throw new Exception(CUtil.GetLastWin32ErrorInfo());
            }

            CloseHandle(hThread);
            FreeLibrary(nLib);
        }