tags:

views:

1151

answers:

3

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

+3  A: 

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.

Konrad Rudolph
I understand from an abstract level that everything is converted to MSIL in the end. However, I've always converted code from C# to VB when I use the code in project. RE: Sharpbits I tried to add the classes (.cs) files I couldn't reference their name spaces.
Cj Anderson
Scratch that, I see there is a DLL that I can use. I'll try that.
Cj Anderson
it's completely unnecessary to convert languages. .NET allows mixing of code or libraries of different languages, in the same program or application.
Cheeso
+1  A: 

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.

Davide
A: 

how can I tell when a download is complete?

Barry
You need to add a handler to yourJob.OnJobTransferred then when that fires you need to use the yourjob.Complete() otherwise it will never finalize even though it finished downloading.
Cj Anderson