VB.NET 和 BITS - 后台智能传输服务
有人在 VB.NET 中使用过 BIT 吗? 如果是这样,您有代码示例和建议吗?
我正在查看 SharpBits,但我有一个想要使用 BITS 的 VB 项目。 可以将它与我的 VB.NET 程序一起使用吗? (.NET 2.0) 我很想尝试将 SharpBits.Base 文件夹中的每个类转换为 VB.NET,但我想我会问一下,以防有人以前走过这条路。
编辑:好的,如果你遇到这个问题。 您可以做的是在 Sharpbits.Base 文件夹(您从 codeplex 下载)中,有一个 DLL 您可以在 Bin 目录中引用。 您可以将其添加到您的参考文献中以访问它。 将康拉德标记为答案,因为他很友善地发帖。
进一步编辑:
我设法让 Sharpbits 使用一些快速代码,我将这些代码粘贴在下面,供任何可能偶然发现这个问题的人使用。 就像我上面提到的,将 DLL 添加到您的项目中。
Dim b As New SharpBits.Base.BitsManager
Dim mynewjob As SharpBits.Base.BitsJob = _
b.CreateJob("jobname", SharpBits.Base.JobType.Download)
mynewjob.AddFile("\\server\share\bigfile.zip", "c:\bigfile.zip")
mynewjob.Resume()
您需要编写一些逻辑来检查作业的状态。 一旦达到“已转移”状态,您就可以将其标记为完成。 这会将文件从 .bin 写入您列出的文件名。 对我有帮助的是安装 Windows 支持工具(您可以从 Windows 2003 Cd/DVD 的 sep 工具文件夹中获取它)并使用 Bitsadmin.exe 在调试时查看作业的状态。 希望这对下一个菜鸟有所帮助。 =)
Has any one used BITs in VB.NET? If so, do you have code samples and advice?
I was looking at SharpBits but I have a VB project that I wanted to use BITS for. Is it possible to use it with my VB.NET program? (.NET 2.0) I was tempted to try to convert each class to VB.NET in the SharpBits.Base folder but figured I'd ask in case someone has headed down this route before.
Edit: Ok folks in case you run across this question. What you can do is in the Sharpbits.Base folder (that you download from codeplex) there is a DLL you can reference in the Bin directory. You can add that into your references to access it. Marking Konrad as answer since he was kind enough to post.
Further edit:
I managed to get sharpbits working with some quick code which I pasted below for anyone who might stumble upon this question. Like I mentioned above add the DLL to your project.
Dim b As New SharpBits.Base.BitsManager
Dim mynewjob As SharpBits.Base.BitsJob = _
b.CreateJob("jobname", SharpBits.Base.JobType.Download)
mynewjob.AddFile("\\server\share\bigfile.zip", "c:\bigfile.zip")
mynewjob.Resume()
You'll need to write some logic to check for the status of the job. Once it hits "Transferred" status you can then mark it as complete. This will write the file from a .bin to the file name you listed. Something that helped me was installing the Windows Support Tools (you can get it from a Windows 2003 Cd/DVD in the sup tools folder)and using Bitsadmin.exe to view the status of the job while debugging. Hope this helps the next rookie. =)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有什么理由不能在 VB 中简单地使用 SharpBits 吗? .NET 的优点恰恰是,用不同 .NET 语言编写的库可以无缝地互操作,因此您可以简单地在 VB 中使用 SharpBits,无论它是用哪种 .NET 兼容语言编写的。
Any reason why you can't simply use SharpBits in VB? The advantage of .NET is precisely that libraries written in the different .NET languages can interoperate seamlessly so you can simply use SharpBits in VB, no matter what .NET-compliant language it was written in.
您可以在这里查看:
使用 Windows XP 后台智能传输服务 (BITS) Visual Studio .NET
我从这里开始编写自己的库来管理 BITS,以便通过专用 LAN 传输大视频文件。 示例适用于 NET 1.1,但将其移植到 NET 2.0 应该不难。
You could take a look here:
Using Windows XP Background Intelligent Transfer Service (BITS) with Visual Studio .NET
I have started from here to write my own library to manage BITS to transfer big video file across private LAN. Example are for NET 1.1 but should not be difficult port it to NET 2.0.
这是一个新的替代方案。 Microsoft 的 BITS 团队现在有一个关于 Calling into 的页面使用参考 DLL 的 .NET 和 C# 的 BITS 以及完整的示例调用BITS Manager在 GitHub 上。
我刚刚尝试将它们与 Visual Basic 一起使用; 我的代码最终看起来像这样:
(Note that I also added a reference to a DLL that I downloaded from the BITS Manager source from the Reference DLL directory)
Here's a new alternative. The BITS team at Microsoft now has a page on Calling into BITS from .NET and C# using reference DLLs plus a complete sample call BITS Manager on GitHub.
I've just tried using them with Visual Basic; my code ended up looking like this:
(Note that I also added a reference to a DLL that I downloaded from the BITS Manager source from the Reference DLL directory)