Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. service that collect files..

service that collect files..

Scheduled Pinned Locked Moved C#
sysadminhelp
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    japanreddy
    wrote on last edited by
    #1

    I have written a service that grabs the files in a source directory on a remote server and ftp's to local directory. The service monitors the source directory of the server and collects the files as they come in. The Problem: Sometimes the files are physically present but the service recognizes and at the time of transfer it cannot get handle on them. I gut feeling is - the service tries to grab the file when it is in the process of being tranferred to the source directory. It loses the handle on the file and can never recover thereafter. Any suggestions ! Thanks / Vinayak

    C 1 Reply Last reply
    0
    • J japanreddy

      I have written a service that grabs the files in a source directory on a remote server and ftp's to local directory. The service monitors the source directory of the server and collects the files as they come in. The Problem: Sometimes the files are physically present but the service recognizes and at the time of transfer it cannot get handle on them. I gut feeling is - the service tries to grab the file when it is in the process of being tranferred to the source directory. It loses the handle on the file and can never recover thereafter. Any suggestions ! Thanks / Vinayak

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      The service should maintain a list of files it has tried to copy. If the copy is successful the file can be removed from the list, if not an attempt can be made on the next cycle when it looks for files again.


      "You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar The Second EuroCPian Event will be in Brussels on the 4th of September Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way! My Blog

      J 1 Reply Last reply
      0
      • C Colin Angus Mackay

        The service should maintain a list of files it has tried to copy. If the copy is successful the file can be removed from the list, if not an attempt can be made on the next cycle when it looks for files again.


        "You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar The Second EuroCPian Event will be in Brussels on the 4th of September Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way! My Blog

        J Offline
        J Offline
        japanreddy
        wrote on last edited by
        #3

        Thanks Colin. I have an ftp component that returns the list of files in the source directory as a dataset. But once the file is failed to be tranferred via the Service Component - I go for the next one tranfer it. When the service makes the next attempt - is gets the failed file in the list but fails to transfer saying that "the file can not be found". :-(

        C 1 Reply Last reply
        0
        • J japanreddy

          Thanks Colin. I have an ftp component that returns the list of files in the source directory as a dataset. But once the file is failed to be tranferred via the Service Component - I go for the next one tranfer it. When the service makes the next attempt - is gets the failed file in the list but fails to transfer saying that "the file can not be found". :-(

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          japanreddy wrote: but fails to transfer saying that "the file can not be found". Is the file physically there? Or in the first failed attempt did it remove the file? (Do you remove the files once they are transferred? If yes, could this be happening even if the file fails to transfer?) Another, possible workaround is to build in a wait step before transferring the file. You see the new file for the first time, but you wait until the next cycle of the service before attempting to transfer it. As your FTP component returns the list of files as datasets, you could retain the previous dataset and compare it with the new dataset and transfer files that appear on both. BTW, how often do you check the directory for new files? However, it would be better to find out why the files are failing to transfer and why on the second attempt the file is not found. Does this help?


          "You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar The Second EuroCPian Event will be in Brussels on the 4th of September Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way! My Blog

          J 1 Reply Last reply
          0
          • C Colin Angus Mackay

            japanreddy wrote: but fails to transfer saying that "the file can not be found". Is the file physically there? Or in the first failed attempt did it remove the file? (Do you remove the files once they are transferred? If yes, could this be happening even if the file fails to transfer?) Another, possible workaround is to build in a wait step before transferring the file. You see the new file for the first time, but you wait until the next cycle of the service before attempting to transfer it. As your FTP component returns the list of files as datasets, you could retain the previous dataset and compare it with the new dataset and transfer files that appear on both. BTW, how often do you check the directory for new files? However, it would be better to find out why the files are failing to transfer and why on the second attempt the file is not found. Does this help?


            "You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar The Second EuroCPian Event will be in Brussels on the 4th of September Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way! My Blog

            J Offline
            J Offline
            japanreddy
            wrote on last edited by
            #5

            Yes, the file is physically there, yet - the service cannot transfer it! It did not remove the file on the first attempt. However, if the transfer is successful, I am removing the file from the remote server. Your next point is a valid one, that is about removing the file despite its failure to tranfer. I have blocked the code in two try blocks. In the first try block I try to tranfer the file and remove only if it is successful. Else do not enter the remove block. I liked your approach to the problem. Thanks / Vinayak

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups