hi oobayly,
i need it can auto make the year folder is the folder not exist
Main Topics
Browse All TopicsI use below code to upload data to my FTP server. the 2009 is follow by year. is there a way that when we in year 2010 and it will auto make 2010 folder in my FTP server
My.Computer.Network.Upload
"ftp://www.cohowinery.com/
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
The folllowing site has code on how to check if an FTP directory exists:
http://www.example-code.co
You can then just do the create if doesn't. As for auto-generating it, if you mean on the year 2010 (as in when the calendar changes) you would need to have a service and constantly poll the date. Not really efficient. Just anytime your app runs check the date, if it's 2010 then check if the 2010 folder exists (using the link above), if not create the directory.
hi oobayly,
i try your code. don't work. how to include the below code togehter.
My.Computer.Network.Upload
string.Format("ftp://www.c
"","",True,500)
That's because that code doesn't contain anything to tell it (that I can see) that if the date is 2010 create the folder. You would either need your app to be a service and constantly check the date, or upon loading the app do a check (obviously best to use a Config file for the date rather than hard coding the string).
However if you definately want it to constantly check the date (so that as soon as the new year comes, it generates the folder) I recommend you create a service. Set a timer for X hours/minutes and call the method below.
@angus_young_acdc
The declaration of directoryName uses string.format to get the year component of current date, so when it's run in 2010, it should create the correct folder.
Dim directoryName As String = String.Format("ftp://www.c
@aarontham
Instead if changing your system date for testing, it'd be better to replace
DateTime.Now with new DateTime(2010, 1, 1)
Can you step through the code, and check the value of createDirectory at line 34?
oobayly:
sorry my mistake it work now. in which line i should add below code?
My.Computer.Network.Upload
string.Format("ftp://www.c
"","",True,500)
i also need to add date,months and year in front of the file that i upload. i try below code but it give wrong date and month.
My.Computer.Network.Upload
string.Format("ftp://www.c
"","",True,500)
Well, I'd suggest you put the create directory code into a method called something like
private sub CreateRemoteDirectory(dire
end sub
Then call that subroutine before using the My.Computer.Network.Upload
As for adding further directories problem:
The Month format is MM (mm is minutes), however I'd strongly recommend using the following format as the files will be sorted by date
Dim directoryName As String = String.Format("ftp://www.c
Business Accounts
Answer for Membership
by: oobaylyPosted on 2009-04-07 at 02:52:04ID: 24085440
Use String.Format, using the year part of the current date
Select allOpen in new window