locked
404 - File or directory not found RRS feed

  • Question

  • Hi to Every one,

    I am doing an application on Wind. Mobile 6.0.

    I want to download photo or image from the server into the device.

    For this I have a list of URL fetched from the server.

    For some of the URL I will copy paste it in browser I will get  "404 - File or directory not found" .

    My doubt:

    Before referring to the URL I want to check whether content is available for that URL

    then I want to proceed to reading the content from server.

    can you please give some kind of source code, or any other help.

    Its neccesary.

    I am using VS 2008, WM 6.0 PPC/SmartPhone, .NET CF 3.0/ 3.5 C#.

     

    Thank you in advance.

     

    Regards,

    Manju

     

     

     

    Friday, July 16, 2010 2:25 PM

Answers

  • I didnt get the solution.

    Finally we planned to get the right URL from the server.

    Before sending URL from the server to the client server side first they check the data then send us the URL.

     

    Thank you.

    Regards

    - Manju

    • Marked as answer by JeevaInMSDN Monday, July 19, 2010 11:57 AM
    Monday, July 19, 2010 11:57 AM

All replies

  • Use an HttpWebRequest to see if there is any content available.
    Friday, July 16, 2010 3:38 PM
  • Hi Ctacke,

    I am using the code like this:

                      Uri strURI = null;

                      HttpWebRequest m_objHttpWebRequest = null; // HTTP Web Request
                      HttpWebResponse m_objHttpWebResponse = null; // HTTP Web Response

                       try
                        {
                            strURI = new Uri(photoURL;
                                                   
                            m_objHttpWebRequest = (HttpWebRequest)HttpWebRequest.Create(strURI);                      
                            m_objHttpWebResponse = (HttpWebResponse)m_objHttpWebRequest.GetResponse();

                            str = m_objHttpWebResponse.GetResponseStream();

                            byte[] inBuf = new byte[102400];

                            int bytesToRead = (int)inBuf.Length;

                            int bytesRead = 0;

                            while (bytesToRead > 0)
                            {
                                int n = str.Read(inBuf, bytesRead, bytesToRead);

                                if (n == 0)
                                    break;

                                bytesRead += n;
                                bytesToRead -= n;
                            }
                        catch(Exception e)

                       {

                           MessageBox.Show("Excepeptio: 404 - File or directory not found ");

                       }

    When it comes to the line or executes GetResponse() line  it will process precess for long time it will keep on same thing but I dont get anything from the server.

    When copy that URL paste it in the browse I will get 404 - File or directory not found.

    I want to check before proceeding to download whether in the specified link data is available or not then go for

    downloading from that URL.

    Please give me the solution.

    How to solve this issue 404 - File or directory not found.

    Thank you for your reply.

    Regards,

    -Manju

    Monday, July 19, 2010 4:18 AM
  • You cannot know that before you get the exception. All you can do is adding a shorter Timeout so that you don't have to wait that long.
    Please mark the post that helps you, and unmark that does not. This benefits our community.
    Monday, July 19, 2010 8:26 AM
  • Hi Tang,

    Thank you for your reply.

    If I add the timeOut Property what happens suppose I am reading a image of some what larger size

    within the time specified it cant able to read fully the image,  finally it will rise an Exception "The operation has timed-out "

    But this is not favorable.

    Any other alternative way to resolve this issue.

     

    Regards,

    -Manju

     

     

     

    Monday, July 19, 2010 10:18 AM
  • I didnt get the solution.

    Finally we planned to get the right URL from the server.

    Before sending URL from the server to the client server side first they check the data then send us the URL.

     

    Thank you.

    Regards

    - Manju

    • Marked as answer by JeevaInMSDN Monday, July 19, 2010 11:57 AM
    Monday, July 19, 2010 11:57 AM