.NET Components for Mobility

receiving file via desktoplistener.cs problem

Last post 05-19-2007 4:04 PM by KarelSimek. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 12-27-2006 7:18 PM

    receiving file via desktoplistener.cs problem

    Hello,

     We are trying to receive files which are sent by PDA, via desktopListener but after  desktop receives some part of the file without finishing the file transfer the whole process freezes. On the other hand, during the process system does not push exception.

     

     I found that the freezing part is " ObexListenerContext olc = ol.GetContext();" at below you can find whole code
                       public void DealWithRequest()
            {
                while(ol.IsListening)
                {
                    try
                    {
            
         
             
                        ObexListenerContext olc = ol.GetContext();
               
                       
                        ObexListenerRequest olr = olc.Request;
                    
                        string filename = ObexUri.UnescapeDataString(olr.RawUrl.TrimStart(new char[]{'/'}));
                        olr.WriteFile(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + "\\" +             DateTime.Now.ToString("yyMMddHHmmss") + " " + filename);

                        this.Invoke(new AddToListDelegate(AddToList), new object[] {filename});
                    }
                    catch(Exception ex)
                    {
                        break;
                    }
                   
                   
                }
            }

     

    Do you have any suggestions.

     

    Thanks in advance. 

  • 05-19-2007 4:04 PM In reply to

    Re: receiving file via desktoplistener.cs problem

    I had a similar freezing problem and it was coused by writefile method. It happened when the mobilephone user canceled the file transfer (and there was no trailing char i guess).

    Solved by comparing filesize in the header and actual data received.

    The code goes like this: 

     

     ObexListenerContext olc = ol.GetContext();
     ObexListenerRequest olr = olc.Request;

     if (olc.Request.ContentLength64 != olc.Request.InputStream.Length)
     {
                MessageBox.Show("File not finished", "WRONG FILE LENGTH");
     }
     else
     {

           // write file and so on

     } 

     

    Hope this helps,

    Karel
    Prague

Page 1 of 1 (2 items)
Copyright © 2001-2008 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy.