• 大小: 157KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-27
  • 语言: C#
  • 标签:

资源简介

WCF大文件上传下载,有客户端和服务器端,服务器为服务。没有整理的demo,可以使用。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using FileClient.FileDownServer;

namespace FileClient
{
    public partial class FileDown : Form
    {
        public FileDown()
        {
            InitializeComponent();
        }
        int cindex = 0;
        long count = 0;
        string downtemp = ““;
        private void button1_Click(object sender EventArgs e)
        {
            FileDownServer.FileDownClient fdc = new FileDownServer.FileDownClient();
            DownFileInfo dfi = fdc.GetFileInfo(“SnowBallTest.rar“);
            string fname = “SnowBallTest.rar“;
            //int cindex = 0;
            //progressBar1.Maximum = dfi.FileLength;
            count = dfi.FileCount;

            //临时目录
            if (!Directory.Exists(Application.StartupPath + “\\downtemp“)) 
            {
                Directory.CreateDirectory(Application.StartupPath + “\\downtemp“);
               
            }
            downtemp = Application.StartupPath + “\\downtemp“;

            SaveFileDialog sfd = new SaveFileDialog();
            sfd.FileName = fname;
           
            if (sfd.ShowDialog() == DialogResult.OK) 
            {
                string savepath = sfd.FileName;
                Directory.CreateDirectory(downtemp + “\\“ + fname);
                //for (int i = 0; i < dfi.FileCount; i++)
                //{
                //    using (FileStream fs = new FileStream(tempFolder + “\\“ + fname + “.“ + i.ToString().PadLeft(9 ‘0‘) +
                //    “-“ + dfi.FileCount
                //     FileMode.Create FileAccess.Write))
                //    {
                //        fs.Write(b 0 b.Length);
                //        label1.Text =fs.Length+ “K/“ + dfi.FileLength+“K“;
                //    }
                //    if (i == dfi.FileCount) 
                //    {
                //        MessageBox.Show(“完毕“);
                //    }
                //}
                
                fdc.GetFileByNameAsync(fname cindex);
                fdc.GetFileByNameCompleted += (bsender be) =>
                {
                    if (be.Error == null)
                    {
                            if (cindex < count) { 
                            using (FileStream fs = new FileStream(downtemp +“\\“ + fname + “\\“ + fname + “.“ + cindex.ToString().PadLeft(9 ‘0‘) +“-“ + count FileMode.Create FileAccess.Write))
                            {
                               
                                fs.Write(be.Result 0 be.Result.Length);
                                label1.Text = fs.Length + “K/“ + dfi.FileLength + “K“;
                                
                            }
                            }
                            if (cindex ==

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1358  2014-11-25 16:28  FileServer\FileClient\App.config

     文件      31744  2014-12-01 11:00  FileServer\FileClient\bin\Debug\FileClient.exe

     文件       1358  2014-11-25 16:28  FileServer\FileClient\bin\Debug\FileClient.exe.config

     文件      77312  2014-12-01 11:00  FileServer\FileClient\bin\Debug\FileClient.pdb

     文件      24224  2014-12-01 11:02  FileServer\FileClient\bin\Debug\FileClient.vshost.exe

     文件       1358  2014-11-25 16:28  FileServer\FileClient\bin\Debug\FileClient.vshost.exe.config

     文件        490  2012-06-06 02:06  FileServer\FileClient\bin\Debug\FileClient.vshost.exe.manifest

     文件       7167  2014-11-25 15:44  FileServer\FileClient\FileClient.csproj

     文件       6806  2014-11-26 12:59  FileServer\FileClient\FileDown.cs

     文件       3720  2014-11-25 17:21  FileServer\FileClient\FileDown.Designer.cs

     文件       5817  2014-11-25 17:21  FileServer\FileClient\FileDown.resx

     文件       4310  2014-11-25 15:16  FileServer\FileClient\FileList.cs

     文件       5861  2014-11-25 15:52  FileServer\FileClient\fileupload.cs

     文件       4255  2014-11-24 15:25  FileServer\FileClient\fileupload.Designer.cs

     文件       5817  2014-11-25 09:38  FileServer\FileClient\fileupload.resx

     文件       1605  2014-11-25 10:26  FileServer\FileClient\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       9622  2014-11-25 16:28  FileServer\FileClient\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       1115  2014-12-01 11:02  FileServer\FileClient\obj\Debug\FileClient.csproj.FileListAbsolute.txt

     文件       1043  2014-11-25 17:21  FileServer\FileClient\obj\Debug\FileClient.csproj.GenerateResource.Cache

     文件       2528  2014-11-25 09:11  FileServer\FileClient\obj\Debug\FileClient.csprojResolveAssemblyReference.cache

     文件      31744  2014-12-01 11:00  FileServer\FileClient\obj\Debug\FileClient.exe

     文件        180  2014-11-25 17:21  FileServer\FileClient\obj\Debug\FileClient.FileDown.resources

     文件        180  2014-11-25 15:44  FileServer\FileClient\obj\Debug\FileClient.fileupload.resources

     文件      77312  2014-12-01 11:00  FileServer\FileClient\obj\Debug\FileClient.pdb

     文件        180  2014-11-25 15:44  FileServer\FileClient\obj\Debug\FileClient.Properties.Resources.resources

     文件          0  2014-11-24 11:28  FileServer\FileClient\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2014-11-24 11:28  FileServer\FileClient\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2014-11-24 11:28  FileServer\FileClient\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件      14336  2014-11-25 16:28  FileServer\FileClient\obj\Debug\TempPE\Service References.FileDownServer.Reference.cs.dll

     文件       8192  2014-11-25 10:26  FileServer\FileClient\obj\Debug\TempPE\Service References.UploadServiceReference.Reference.cs.dll

............此处省略78个文件信息

评论

共有 条评论

相关资源