473,387 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 :(
Sep 7 '10 #1
3 1865
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
Sep 7 '10 #2
Hi Mr. Martijn,

I double checked the file paths and they all coincide with each other. Also p2 only reads the file, using WebRequestMethods.FTP.DownloadFile. 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 :)
Sep 8 '10 #3
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!
Sep 8 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: JKop | last post by:
Would you classify the following code as "Undefined Behaviour" or as "Non- portable"? signed main() { signed char chedder = 130; } Relevant information:
1
by: Mat DeLong | last post by:
Can someone explain this error to me? : main.cpp:9: instantiated from `void show(const LIST::List<T>&) ' main.cpp:23: instantiated from here list.cpp:58: error: dependent-name...
15
by: Sander Tekelenburg | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The HTML specs speak of "replaced" and "non-replaced" elements, yet for the life of me I can't find an explanation of what "replaced" is supposed...
5
by: Verde | last post by:
I'm using a 3rd party component in an ASP.NET 1.1 Web application. The component has a .Click event that can be fired from the client, with an associated event procedure in the code-behind module....
8
by: Bern McCarty | last post by:
Is it at all possible to leverage mixed-mode assemblies from AppDomains other than the default AppDomain? Is there any means at all of doing this? Mixed-mode is incredibly convenient, but if I...
1
by: alex23 | last post by:
Hey everyone, I'm trying to install setuptools on a work PC behind an NTLM firewall. I've tried to use APS as recommended but am still unable to have anything other than IE talk through...
3
by: Arnost Sobota | last post by:
Dear ASP community, I have a question regarding ASP session variables. My assumption was that a session variable has the same lifetime as the session itself: as a consequence, given that...
5
by: Aneesh Pulukkul[MCSD.Net] | last post by:
How to convert a "Non Serializable" object to byte array. The object is a dynamically created Excel workbook. As per my understanding an object can be written and read from a stream Only if it's...
3
by: Harsha | last post by:
Hi all, I used simplexml_load_file function to parse all my xml feeds, and found it to be the easiest option available. But, i recently signed up for a feed which sends the xml file without the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.