比特, 锐比特.net

发布于 2024-12-09 20:52:13 字数 2096 浏览 1 评论 0原文

我在我的项目中使用 BITS - 后台智能传输服务来发送大尺寸文件。在 C# 代码中使用 SharpBITS.NET。 我想将文件从服务器上传到客户端。我现在记下侧面。

-------------客户端----------------

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);

        }
    }

这是一个简单的控制台应用程序。本地——我要发送的文件的路径,目的地——路径是接收者,它是远程服务器。 当我运行程序作业时。Error take mi follow ---“服务器的响应无效。服务器未遵循定义的协议。恢复作业,然后后台智能传输服务(BITS)将重试。-- BG_E_HTTP_ERROR_200 .-2145845048, 0x801900C8"

对于客户端(接收器),我有以下代码:它是 Mvs 3 小项目,我只查看动作 我们的目的地路径要去哪里。

 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"));*/
}

但 FileUpload 操作未接收文件。我不知道如何在客户端接收文件。 如您所见,我使用 HttpPostedFileBase 来接收文件,但这不起作用。

我的主机服务器是 Windows Server 2008 r2,我完成了 BITS 所需的步骤。有关详细信息,您可以访问以下网站 http://technet.microsoft.com/ en-us/library/cc431377.aspx ---- 如何为 Configuration Manager 2007 站点系统配置 Windows Server 2008。

所以我不知道做什么才能在主机服务器中接收文件。你可以告诉我你能做什么。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

再浓的妆也掩不了殇 2024-12-16 20:52:13

使用 Web 应用程序使用的无状态方法,一旦响应完成,就不会连接到服务器。您可以从客户端轮询服务器,但客户端不会监听服务器发送额外的位。

在“过去”,您可以设置 ActiveX 控件、Java 小程序等(今天的 Silverlight?)来继续监听,但这不是直接的 Web 风格开发。

如果您愿意使用 websocketAPI,HTML5 会扩展您的选择。与 HTML5 的所有部分一样,使用这些位进行实现会面临一些风险,因为并非所有浏览器都采用了“标准”(预计将在未来 10-12 年内完成采用:->)。

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:->).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文