Maybri
Posts: 8
Joined: Thu Mar 16, 2006 3:22 am

Problem with the GetFileAsync() Method

Thu Mar 16, 2006 3:29 am

Hi, we are making an application in Windows XP SP2. We are using Visual Studio .Net 1.1 and an HP Pocket Pc 3115. Until now, we have been able to pass information from the computer to the pocket PC, but we can´t pass information from the Pocket PC to the computer. Here is this part of our code:

FileStream fw=new FileStream("Class2.txt",FileMode.Create,FileAccess.Write);
fb.SetPathAsync("\\My Documents\\Personal");
fb.GetPathAsync();
fb.GetFileAsync(fw,"Class1.txt");
fw.Close();
fb.DisconnectAsync();

We would appreciate if you could tell us what's wrong in it, because we have compared this code with other examples included in the library and it is very similar.

Thank you.

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: Problem with the GetFileAsync() Method

Thu Mar 16, 2006 11:07 am

You are closing the FileStream right after calling GetFileAsync. Remember that asynchronous methods returns right after they are called and are executed in their own thread.

A better way to do it is to call both fw.Close() and fb.DisconnectAsync() from the event handler of fb.GetFileEnd which is called when the GetFileAsync() method has finished.

Regards,
Jonas
Franson Support

Return to “BlueTools”