bits , sharpBits.net

859 views Asked by At

I using in my project BITS - Background Intelligent Transfer Service for send file with larg size. Using SharpBITS.NET in C# code. I want to upload file from server to client. I now note the sides.

-------------client side---------------

static void Main(string[] args) {

        string local = @"I:\a.mp3";

        string destination = "http://192.168.56.128/BitsTest/Home/FileUpload";

        string remoteFile = @destination;
        string localFile = local;
        if (!string.IsNullOrEmpty(localFile) && System.IO.File.Exists(localFile))
        {
            var bitsManager = new BitsManager();
            var job = bitsManager.CreateJob("uploading file", JobType.Upload);
            job.NotificationFlags = NotificationFlags.JobErrorOccured |      NotificationFlags.JobModified |
                                    NotificationFlags.JobTransferred;

            job.AddFile(remoteFile, localFile);
            job.Resume();

            job.OnJobError += new EventHandler<JobErrorNotificationEventArgs>(job_OnJobError);

        }
    }

This is a simple console application. the local -- path the file that I want to send, destination -- the path is receiver it is remote server. When I run program the job.Error take mi follow --- "The server's response was not valid. The server was not following the defined protocol. Resume the job, and then Background Intelligent Transfer Service (BITS) will try again. -- BG_E_HTTP_ERROR_200 .-2145845048, 0x801900C8"

For Client (receiver) i have the follow code: It is Mvs 3 small project and I View only action where to go by our destination path.

 public ActionResult FileUpload()
        {
            try
            {
                HttpPostedFileBase file = Request.Files[0];
                file.SaveAs(System.IO.Path.Combine(Server.MapPath("/BitsTest/"), file.FileName));
            }
            catch
            { }
            /*System.IO.File.Move(Server.MapPath("/BitsTest/bin/aa.png"), Server.MapPath("/BitsTest/Content/aa.png"));*/
}

But FileUpload action thas not recevie file. I don't know how I can receive file in client Side. As you can see, I used HttpPostedFileBase for recive file but that is not working.

My host server is Windows server 2008 r2 and I done needed steps for BITS. For more information you can visit the follow site http://technet.microsoft.com/en-us/library/cc431377.aspx ---- How to Configure Windows Server 2008 for Configuration Manager 2007 Site Systems.

So I don't know what doing that I can receive file in host server.You can tell me what you can do.

1

There are 1 answers

0
Gregory A Beamer On

With a stateless methdology like the one web applications use, there is no connection to the server once the response is completed. You can poll the server from the client side, but the client is not listening for the server to send additional bits.

In "the past" you could set up ActiveX controls, Java applets, etc (Silverlight today?) to continue to listen, but this is not straight web style development.

HTML5 expands your options, if you are willing to use the websocketAPI. As with all parts of HTML5, you have some risk using these bits for implementation as not all browsers have adopted the "standard" yet (adoption expected to be complete in the next 10-12 years:->).