FTP file download works but opens old "non-existent" file.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Javier Avalos
    New Member
    • Sep 2010
    • 3

    FTP file download works but opens old "non-existent" file.

    Hi folks, first thank you very much for your potential help in reducing my headache and teaching me a thing or two! :)

    I have two programs, one saves a local copy .txt file with info, and also uploads this same .txt file to a ftp server, it does this with updated information at an interval of 30 seconds. All of this works, if I log into the FTP I open the .txt file and sure enough, the new .txt file is there and updates normally, every 30 seconds.

    The second program simply tries to download this .txt file from the FTP server, tried as a windows form and from asp on the server itself. This task only runs at my discretion, so no timer is set. My problem is here, the file is successfully downloaded and read, however, after its updated (verified even by logging in physically to the ftp server) the output of the program continues to be the old text file and gets a new one a few minutes or whenever the heck it wants to really after stopping the auto upload, or God knows what I really have not come to a exact conclusion as to when it actually successfully downloads the updated text file.

    So my questions are really the following;
    I have closed all ftp connections after running the ftp upload, all the streams and so on...closed; it IS every 30 seconds and I'm thinking somehow i manage to try to connect at the same time to the file ? but then WHY do I get the OLD file (even after more than 1 update it still shows file number one per se).

    OK GOsh I suck at explaining problems,

    OK program 1 = p1
    program 2 = p2


    p1 - writes timestamp to ping.txt ---> sends to FTP (succeeds)
    - repeats every 30 seconds (succeeds)

    p2 - connects to ftp and downloads the ping.txt and reads it onto a string var DaPing per se


    ok so

    p1 ---
    puts 4:03pm
    ....30 secs go by
    puts 4:03pm
    ....30 secs go by
    puts 4:04pm
    ....30 secs go by
    puts 4:04pm
    ....30 secs go by
    puts 4:05pm
    ....30 secs go by
    puts 4:05pm
    ....etc twice every minute


    NOW p2 checks lets say at 4:05, and 4:10

    the file that p2 READS still says 4:03pm
    if i go to the ftp myself via client the file I open is 4:0x whatever the last one put was.

    WHY is this happening? :( and how do I fix, if it is time related or connection related what could it be and why?

    Thanks so much guys, I apologize for my long windedness I just really lack any other form of communication :P I tried though I promise :(
  • MartijnHoekstra
    New Member
    • Sep 2010
    • 39

    #2
    Few things you could double check:
    1)
    The exact folder where you are downloading the ping.txt file ? Maybe you are downloading to another folder and you keep checking the other.
    2)
    Once you downloaded first file, is p2 able to 'overwrite' the already existing file? Have you checked that part to have any exceptions or error messages? Try remove the existing file, run p2 again and see whether it appears then with correct timestamp

    Comment

    • Javier Avalos
      New Member
      • Sep 2010
      • 3

      #3
      Hi Mr. Martijn,

      I double checked the file paths and they all coincide with each other. Also p2 only reads the file, using WebRequestMetho ds.FTP.Download File. Are you suggesting to try and open/create the text file see if that works to check if p2 has access to the file? And also thought i'd update this thread on the fact that I found a general flaw on my design since multiple computers would be writing their own data onto that ONE .txt file, all at an interval of time x, so realized that....yeah can't quite do that elegantly in a way that I can just install the application as a service without tweaking or modifying timing each time I'd have another computer use the service. So I have a new design with multiple .txt files (btw all of this because I have no access to my web server's options when it comes to remote access to mysql..... because I would just love to save this to mysql db instead). But nonetheless I want to know why or how is it possible for the application to "DOWNLOAD" a file AGAIN from ftp and receive something that is technically no longer there?!? specially after consequent saves to the file, as in the file is overwritten ten times.... pretty much should guarantee that the file downloaded is not file #1... but another note is that in my code I had accessed the file consecutively pretty fast so I added thread.sleep for the second access and that seems to have "fixed" or improved the situation when it comes to retrieving an updated copy of the file, but now my flaw came to light, but still I want to know why or how is it possible for the request to return a file that doesn't technically exist anymore?!? Also any ideas on file management where multiple computers could in theory update information on a server remotely (without databases) using 1 file, or having all the information in one file rather than multiple ones (although my solution that I will implement is not very inelegant using the different files) but I would still like to pick your brain(s). Thanks again :)

      Comment

      • Javier Avalos
        New Member
        • Sep 2010
        • 3

        #4
        Oh btw thank you personally Mr. Martijn for your prompt response, I had written my previous post once before and thanking you but I am now using google chrome and accidentally closed all my tabs losing my reply.......... ............... .. so I rewrote it and forgot to thank you first and foremost ;) so thanks!
        Last edited by Javier Avalos; Sep 8 '10, 05:45 AM. Reason: loosing -> losing

        Comment

        Working...