Пример #1
0
        private void btnContinue_Click(object sender, EventArgs e)
        {
            string sFileName = "";

            for (int i = 0; i < lvFileData.Items.Count; i++)
            {
                if (lvFileData.Items[i].Checked)
                {
                    sFileName = lvFileData.Items[i].SubItems[1].Text.ToString();
                    break;
                }
            }
            sFileName = sFileName.Trim();
            if (m_iLogonID < 0 || sFileName == "")
            {
                return;
            }

            UInt32 iConnID = 0;

            if (IsFileInList(m_iLogonID, sFileName, ref iConnID))
            {
                DOWNLOAD_CONTROL tdc = new DOWNLOAD_CONTROL();// = {sizeof(DOWNLOAD_CONTROL)};
                tdc.m_iSize     = Marshal.SizeOf(tdc);
                tdc.m_iPosition = -1;
                tdc.m_iSpeed    = 16;
                tdc.m_iReqMode  = cbQueryMode.SelectedIndex;
                int iRet = NVSSDK.NetClient_NetFileDownload(ref iConnID, m_ClientInfo.m_iServerID, 2, StructToBytes(tdc), Marshal.SizeOf(tdc));
                //if (iRet < 0)
                //{
                //    MessageBox.Show("NetClient_NetFileDownload faild!");
                //}
            }
        }
Пример #2
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            string sFileName = "";

            for (int i = 0; i < lvFileData.Items.Count; i++)
            {
                if (lvFileData.Items[i].Checked)
                {
                    sFileName = lvFileData.Items[i].SubItems[1].Text.ToString();
                    break;
                }
            }
            //sFileName = sFileName.Trim();
            if (m_iLogonID < 0 || sFileName == "")
            {
                return;
            }

            UInt32 iConnID = 0;

            if (IsFileInList(m_iLogonID, sFileName, ref iConnID))
            {
                return;
            }
            if (!System.IO.Directory.Exists("E:\\netclientdemo_download"))
            {
                System.IO.Directory.CreateDirectory("E:\\netclientdemo_download");
            }
            //int iRet = NetClient_NetFileDownloadFile(&iConnID, m_iLogonID, (char *)(LPCSTR)m_szFileName, (char *)(LPCSTR)(g_szDownloadPath + m_szFileName), 0, -1, -1);
            DOWNLOAD_FILE tdf = new DOWNLOAD_FILE();    //= {sizeof(DOWNLOAD_FILE)};

            tdf.m_cRemoteFilename = new char[255];
            tdf.m_cLocalFilename  = new char[255];
            //strcpy_s(tdf.m_cRemoteFilename,m_szFileName.GetLength()+1,(char *)(LPCSTR)m_szFileName);
            //strcpy_s(tdf.m_cLocalFilename,(g_szDownloadPath + m_szFileName).GetLength()+1,(char*)(LPCSTR)(g_szDownloadPath + m_szFileName));

            CharsCopy(sFileName.ToCharArray(), tdf.m_cRemoteFilename);
            //tdf.m_cRemoteFilename = sFileName.ToCharArray();
            CharsCopy(("E:\\netclientdemo_download\\" + sFileName).ToCharArray(), tdf.m_cLocalFilename);
            //tdf.m_cLocalFilename = "c:\\netclientdemo_download\\".ToCharArray();
            tdf.m_iPosition = -1;
            tdf.m_iSpeed    = 32;
            tdf.m_iReqMode  = cbQueryMode.SelectedIndex;

            int iRet = NVSSDK.NetClient_NetFileDownload(ref iConnID, m_ClientInfo.m_iServerID, 0, StructToBytes(tdf), Marshal.SizeOf(tdf));

            if (iRet >= 0)
            {
                //int iRet = NetClient_NetFileDownloadFile(&iConnID, m_iLogonID, (char *)(LPCSTR)m_szFileName, (char *)(LPCSTR)(g_szDownloadPath + m_szFileName), 1, -1, 16);//设置下载速度为32倍速
                DOWNLOAD_CONTROL tdc = new DOWNLOAD_CONTROL();        // = {sizeof(DOWNLOAD_CONTROL)};
                tdc.m_iSize     = Marshal.SizeOf(tdc);
                tdc.m_iPosition = -1;
                tdc.m_iSpeed    = 16;
                tdc.m_iReqMode  = cbQueryMode.SelectedIndex;
                iRet            = NVSSDK.NetClient_NetFileDownload(ref iConnID, m_ClientInfo.m_iServerID, 2, StructToBytes(tdc), Marshal.SizeOf(tdc));
                Download downloadfile = new Download(m_iLogonID, iConnID, sFileName, "", "");
                if (cbBreakContinue.Checked)
                {
                    downloadfile.SetBreakContinue(1);
                }
                else
                {
                    downloadfile.SetBreakContinue(0);
                }

                downloadfile.SetReqMode(tdc.m_iReqMode);
                m_lstDownloadFile.Add(downloadfile);
                timerFile.Enabled = true;
            }
        }