コード例 #1
0
        private static void UploadFile(string fileName)
        {
            IniWrapper ini          = new IniWrapper("c:\\ftp.ini");
            string     host         = ini.ReadValue("FTP", "HOST");
            string     user         = ini.ReadValue("FTP", "USER");
            string     pass         = ini.ReadValue("FTP", "PASS");
            string     localpath    = ini.ReadValue("FTP", "LOCALPATH");
            string     remotepath   = ini.ReadValue("FTP", "REMOTEPATH");
            FtpClient  client       = new FtpClient(host, user, pass);
            FileInfo   info         = new FileInfo(fileName);
            string     relativePath = info.DirectoryName.Replace("\\", "/") + "/" + info.Name;

            relativePath = relativePath.Replace(localpath, "");
            string remoteFilePath = remotepath + relativePath;

            client.Upload(info, remoteFilePath);
        }
コード例 #2
0
        void IContextMenu.InvokeCommand(IntPtr pici)
        {
            INVOKECOMMANDINFO ici   = (INVOKECOMMANDINFO)Marshal.PtrToStructure(pici, typeof(ShellLib.INVOKECOMMANDINFO));
            StringBuilder     sb    = new StringBuilder(1024);
            StringBuilder     sbAll = new StringBuilder();
            uint nselected;

            switch (ici.verb)
            {
            case 0:
                //上传
                nselected = Helpers.DragQueryFile(m_hDrop, 0xffffffff, null, 0);
                for (uint i = 0; i < nselected; i++)
                {
                    ShellLib.Helpers.DragQueryFile(m_hDrop, i, sb, sb.Capacity + 1);
                    string     filePath = sb.ToString();
                    IniWrapper ini      = new IniWrapper("c:/log.ini");
                    ini.WriteValue("LOG", "FILE", filePath);
                    UploadFile(filePath);
                }
                break;

            case 1:
                //下载
                nselected = Helpers.DragQueryFile(m_hDrop, 0xffffffff, null, 0);
                for (uint i = 0; i < nselected; i++)
                {
                    ShellLib.Helpers.DragQueryFile(m_hDrop, i, sb, sb.Capacity + 1);
                    string filePath = sb.ToString();
                    DownloadFile(filePath, false);
                }
                break;

            case 2:
            {
                //查看
                IniWrapper ini  = new IniWrapper("c:\\ftp.ini");
                string     tool = ini.ReadValue("FTP", "TOOL");
                FileInfo   info = new FileInfo(tool);
                if (info.Exists == false)
                {
                    tool = "notepad";
                }

                nselected = Helpers.DragQueryFile(m_hDrop, 0xffffffff, null, 0);
                string args = "";
                for (uint i = 0; i < nselected; i++)
                {
                    ShellLib.Helpers.DragQueryFile(m_hDrop, i, sb, sb.Capacity + 1);
                    string filePath = sb.ToString();
                    DownloadFile(filePath, true);
                    args += filePath;
                    args += ".bak ";
                }

                Process proc = new Process();
                proc.StartInfo.FileName  = tool;
                proc.StartInfo.Arguments = args;
                proc.Start();
            }

            break;

            default:
                break;
            }
        }
コード例 #3
0
ファイル: MyContextMenu.cs プロジェクト: radtek/isoftstone
 private static void UploadFile(string fileName)
 {
     IniWrapper ini = new IniWrapper("c:\\ftp.ini");
     string host = ini.ReadValue("FTP", "HOST");
     string user = ini.ReadValue("FTP", "USER");
     string pass = ini.ReadValue("FTP", "PASS");
     string localpath = ini.ReadValue("FTP", "LOCALPATH");
     string remotepath = ini.ReadValue("FTP", "REMOTEPATH");
     FtpClient client = new FtpClient(host, user, pass);
     FileInfo info = new FileInfo(fileName);
     string relativePath = info.DirectoryName.Replace("\\", "/") + "/" + info.Name;
     relativePath = relativePath.Replace(localpath, "");
     string remoteFilePath = remotepath + relativePath;
     client.Upload(info, remoteFilePath);
 }
コード例 #4
0
ファイル: MyContextMenu.cs プロジェクト: radtek/isoftstone
        void IContextMenu.InvokeCommand(IntPtr pici)
        {
            INVOKECOMMANDINFO ici = (INVOKECOMMANDINFO)Marshal.PtrToStructure(pici, typeof(ShellLib.INVOKECOMMANDINFO));
            StringBuilder sb = new StringBuilder(1024);
            StringBuilder sbAll = new StringBuilder();
            uint nselected;

            switch (ici.verb)
            {
                case 0:
                    //上传
                    nselected = Helpers.DragQueryFile(m_hDrop, 0xffffffff, null, 0);
                    for (uint i = 0; i < nselected; i++)
                    {
                        ShellLib.Helpers.DragQueryFile(m_hDrop, i, sb, sb.Capacity + 1);
                        string filePath = sb.ToString();
                        IniWrapper ini = new IniWrapper("c:/log.ini");
                        ini.WriteValue("LOG","FILE",filePath);
                        UploadFile(filePath);
                    }
                    break;
                case 1:
                    //下载
                    nselected = Helpers.DragQueryFile(m_hDrop, 0xffffffff, null, 0);
                    for (uint i = 0; i < nselected; i++)
                    {
                        ShellLib.Helpers.DragQueryFile(m_hDrop, i, sb, sb.Capacity + 1);
                        string filePath = sb.ToString();
                        DownloadFile(filePath,false);
                    }
                    break;
                case 2:
                    {
                        //查看
                        IniWrapper ini = new IniWrapper("c:\\ftp.ini");
                        string tool = ini.ReadValue("FTP", "TOOL");
                        FileInfo info = new FileInfo(tool);
                        if (info.Exists == false)
                        {
                            tool = "notepad";
                        }

                        nselected = Helpers.DragQueryFile(m_hDrop, 0xffffffff, null, 0);
                        string args = "";
                        for (uint i = 0; i < nselected; i++)
                        {
                            ShellLib.Helpers.DragQueryFile(m_hDrop, i, sb, sb.Capacity + 1);
                            string filePath = sb.ToString();
                            DownloadFile(filePath, true);
                            args += filePath;
                            args += ".bak ";
                        }

                        Process proc = new Process();
                        proc.StartInfo.FileName = tool;
                        proc.StartInfo.Arguments = args;
                        proc.Start();
                    }

                    break;
                default:
                    break;
            }
        }