if file exist on the net

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Franck

    if file exist on the net

    i have already a way to know if a file is there by using
    System.Net.WebR equest.Create(s trURL);

    the problem come when checking for huge file. How do i manage that.
    because the code define over there read the entire file and output a
    string in my case. Is there any other system.net object that could
    check only if a file exist.
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: if file exist on the net

    Franck,

    Do you mean on a web server (through the HTTP or HTTPS protocol)? If
    so, you can issue a HEAD statement and check the response code (it will be
    200 if it exists, 404 if not found). Then, if the item exists, you can
    issue a GET (or POST, if that is what you are using) to get the actual
    content.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Franck" <the_darkblast@ hotmail.comwrot e in message
    news:a1870258-f0a6-4041-bc57-01e07864d57c@i7 2g2000hsd.googl egroups.com...
    >i have already a way to know if a file is there by using
    System.Net.WebR equest.Create(s trURL);
    >
    the problem come when checking for huge file. How do i manage that.
    because the code define over there read the entire file and output a
    string in my case. Is there any other system.net object that could
    check only if a file exist.

    Comment

    • Franck

      #3
      Re: if file exist on the net

      sorry i forgot to explain all. Im using C# windows app and the purpose
      is for update application. We already have a webservice on the server
      and we use the same server on http port to get the file. i download it
      without problem it's just that now i need to add a check if the file
      exist.

      separate Exe which use System.Net.WebR equest.Create(s trURL); on an
      xml file on the server that contain the current version. if empty
      result mean the user is offline. if it return something i compare the
      versions and if higher i update the program.

      Comment

      • Nicholas Paldino [.NET/C# MVP]

        #4
        Re: if file exist on the net

        Franck,

        Not to get completely off topic, but since .NET 2.0 (and even before,
        with the updater application block in the enterprise library), you haven't
        had to do this for yourself because of ClickOnce.

        You might want to look into that, as I imagine it will make your life
        much, much easier.


        --
        - Nicholas Paldino [.NET/C# MVP]
        - mvp@spam.guard. caspershouse.co m

        "Franck" <the_darkblast@ hotmail.comwrot e in message
        news:1a26a29c-fc3f-4fb6-8e56-b351fec334eb@i7 g2000prf.google groups.com...
        sorry i forgot to explain all. Im using C# windows app and the purpose
        is for update application. We already have a webservice on the server
        and we use the same server on http port to get the file. i download it
        without problem it's just that now i need to add a check if the file
        exist.
        >
        separate Exe which use System.Net.WebR equest.Create(s trURL); on an
        xml file on the server that contain the current version. if empty
        result mean the user is offline. if it return something i compare the
        versions and if higher i update the program.

        Comment

        • Franck

          #5
          Re: if file exist on the net

          thanks im checking if right now

          Comment

          • Franck

            #6
            Re: if file exist on the net

            I tested it and it work on a test project, but our project have too
            much dependencies to use that installer. According to the list of
            feature i found, the apllication is only install for one user and
            inside what's called "clickonce application cache." we actually need
            it to be install on multiple user. We aslo have old unmanage dll that
            we need to register when first installed. Unless there is special
            extra feature somewhere we will keep the basic installer and update im
            working on.

            So i ask the question again.

            Is there a way to know if a file exist using URL ?

            Comment

            • Nicholas Paldino [.NET/C# MVP]

              #7
              Re: if file exist on the net

              Franck,

              The method I gave you before will work for HTTP/HTTPS urls, where you
              issue a HEAD request to get just the headers. If you get a 200 response,
              then you know the item is there. If you get a 404 response, then you know
              it doesn't exist.

              --
              - Nicholas Paldino [.NET/C# MVP]
              - mvp@spam.guard. caspershouse.co m

              "Franck" <the_darkblast@ hotmail.comwrot e in message
              news:c64e96b6-5e0e-431a-8b5e-3d6d29350bea@s3 7g2000prg.googl egroups.com...
              >I tested it and it work on a test project, but our project have too
              much dependencies to use that installer. According to the list of
              feature i found, the apllication is only install for one user and
              inside what's called "clickonce application cache." we actually need
              it to be install on multiple user. We aslo have old unmanage dll that
              we need to register when first installed. Unless there is special
              extra feature somewhere we will keep the basic installer and update im
              working on.
              >
              So i ask the question again.
              >
              Is there a way to know if a file exist using URL ?

              Comment

              Working...