loading files to server
-
Hello friends, I am Usind MSAccess for loading some txtfiles from a folder to the SQL server. These txtfiles are gnerated from a testing tool. My Access will autoload the files to the server i.e my application is scheduled to call from scheduled task, twice a day. It will check the folder for txtfiles , if the folder is empty, the applicaton exits. Else it will load the files to server and move all loaded files to another folder. My problem is if both tool(my MSAccess and the testing tool which creating txt files) are running simultanously these is a chance of half generated txt file(generating by testing tool) to be loaded in the server. I dont want that. That file has to be loaded next time. How to prevent the half generated txtfiles from loading to server. Hope u got my problem Regards Jishith
-
Hello friends, I am Usind MSAccess for loading some txtfiles from a folder to the SQL server. These txtfiles are gnerated from a testing tool. My Access will autoload the files to the server i.e my application is scheduled to call from scheduled task, twice a day. It will check the folder for txtfiles , if the folder is empty, the applicaton exits. Else it will load the files to server and move all loaded files to another folder. My problem is if both tool(my MSAccess and the testing tool which creating txt files) are running simultanously these is a chance of half generated txt file(generating by testing tool) to be loaded in the server. I dont want that. That file has to be loaded next time. How to prevent the half generated txtfiles from loading to server. Hope u got my problem Regards Jishith
-
Hello friends, I am Usind MSAccess for loading some txtfiles from a folder to the SQL server. These txtfiles are gnerated from a testing tool. My Access will autoload the files to the server i.e my application is scheduled to call from scheduled task, twice a day. It will check the folder for txtfiles , if the folder is empty, the applicaton exits. Else it will load the files to server and move all loaded files to another folder. My problem is if both tool(my MSAccess and the testing tool which creating txt files) are running simultanously these is a chance of half generated txt file(generating by testing tool) to be loaded in the server. I dont want that. That file has to be loaded next time. How to prevent the half generated txtfiles from loading to server. Hope u got my problem Regards Jishith
In the old days (VAX/VMS) I used to be able to open a file either as "Shared" or "Exclusive". What you want here is to open the file, "Exclusive", so that you are guaranteed that that no other process is touching it. You will need to test this out with OpenTextFile in MS-Access. Just and idea.
-
Hello friends, I am Usind MSAccess for loading some txtfiles from a folder to the SQL server. These txtfiles are gnerated from a testing tool. My Access will autoload the files to the server i.e my application is scheduled to call from scheduled task, twice a day. It will check the folder for txtfiles , if the folder is empty, the applicaton exits. Else it will load the files to server and move all loaded files to another folder. My problem is if both tool(my MSAccess and the testing tool which creating txt files) are running simultanously these is a chance of half generated txt file(generating by testing tool) to be loaded in the server. I dont want that. That file has to be loaded next time. How to prevent the half generated txtfiles from loading to server. Hope u got my problem Regards Jishith
We use a first pass flag. We know the write does not take more than x seconds so the loop sets a time flag the first pass. Second pass if the time flag is > wait setting then the file is loaded. I almost like the exclusive idea (and will test it Monday) except you are programming by error (one of my favourite rants) ie try and open the file, if it fails then deal with it.
Never underestimate the power of human stupidity RAH
-
We use a first pass flag. We know the write does not take more than x seconds so the loop sets a time flag the first pass. Second pass if the time flag is > wait setting then the file is loaded. I almost like the exclusive idea (and will test it Monday) except you are programming by error (one of my favourite rants) ie try and open the file, if it fails then deal with it.
Never underestimate the power of human stupidity RAH
-
the txt file may take minute for complete write.. And its with the customer side..i dont want to fail my application while opening..Want to load other file skipping the file which is still in writing process..
jishbalan wrote:
Want to load other file skipping the file which is still in writing process.
That is precisely what we do. If the file has not been resident in the folder for #n seconds then the loop progresses to the next file in the folder and ignores the potentially locked file. Next pass it will get the file it ignored.
Never underestimate the power of human stupidity RAH
-
jishbalan wrote:
Want to load other file skipping the file which is still in writing process.
That is precisely what we do. If the file has not been resident in the folder for #n seconds then the loop progresses to the next file in the folder and ignores the potentially locked file. Next pass it will get the file it ignored.
Never underestimate the power of human stupidity RAH
-
Thanks a lot.. These is exactly what i want... But "If the file has not been resident in the folder for #n seconds" What it means? and how to check? "potentially locked file" How can i check for these?
You need a table/list of filenames with a datetime field. Start loop (foreach file in directory) check if the file is in the list add the file to the list with the time (first pass) if the file is there has enough time passed (check time flag in list for this file) if time passed > Setting then process end loop A potentially locked file has been in the folder less than #n seconds/minutes. You really don't care if it is actually locked, just make sure the time to wait is > than any possible locking period.
Never underestimate the power of human stupidity RAH