Link to home
Start Free TrialLog in
Avatar of ocamporuss
ocamporuss

asked on

Delete files on ftp server

Greetings,

I have created a program using vb.net which allows users to upload files on an ftp server and share them via a link that the program generates at the end of the upload.

To save space on my ftp server, I will only be keeping the uploaded files for a set time (in this case 7 days) and would delete files older than that.

For that I am creating a separate program (still using vb.net) that will run unattended on my PC. I am aiming for this to check the ftp server every now and then, check all existing files at that moment and see if they are 7 days or older then delete such files.

Unfortunately, I cannot seem to find a way to "detect" the date the file was uploaded (modified date) and run a procedure to check if it is already more than 7 days old.

I have used the function WebRequestMethods.Ftp.ListDirectoryDetails but it returns strings which I have no way of isolating the file date (and it also does not provide the year, which would be a problem to compute how old the file is if it was uploaded towards the end of the year)

Any suggestions on how I can get about deleting files on my ftp server that are a certain amount of days old?

Thank you and regards.
Avatar of andygrant2005
andygrant2005
Flag of United Kingdom of Great Britain and Northern Ireland image

I'll be totally honest here and say I have never had to get the modified date of a file on an FTP platform before, but the code I use to find the file modified date on your local file system is :


FDate = IO.File.GetLastWriteTime(FName)


I can see no reason why this wouldn't work for you.

Let me know how it goes.
SOLUTION
Avatar of guvera
guvera
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ocamporuss
ocamporuss

ASKER

Thank you all for your feedback.

@andygrant2005: Please correct me if I am wrong, but taking the date from a local file would mean I would have to download all the existing files on the ftp server to my PC first before I could check each of them out. Given that my program would be used by 200+ people in my company, there would be a lot of files at any given time and it may not be feasible for me to do so in my situation.

@guvera: Looking at the link you have provided, I assume that this is a script that runs on the ftp server itself. This may be my fallback if I am unable to actually to do what I wanted to using my second program. This is because my file upload program has the capacity to upload to several ftp servers that our company has for redundancy purposes. And to have to configure each server may be more complicated for me (as i have never done it before) than to have a program do it for me irrespective of the server.

@CodeCruiser: The link you have provided looks promising. I will give it a try and see how it goes.

@PaulNSW: It is feasible for me on my own to create an account with Zendto or with any other free/paid web-based file sharing system. But I think (and this goes with my current company) that most businesses with enough resources would rather keep their files managed by themselves rather than have a third party do it instead.

Thank you and regards.
ZendTo is a free software product that you deploy on your own server, it is not a 3rd party service/intermediary. Your files are hosted on whatever server/VM you have in your environment, as is the ZendTo server.  You have full control over who has access, whether it links in with your AD domain, when files are automatically deleted, the maxium file size a user can send, whether you use SSL etc
Dear All,

Sorry for the delayed response.

@PaulNSW: Thank you for clarifying. I have taken a deeper look at ZendTo and have decided to make it as my fallback should I be unable to do what I would like with my program.