Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please help, I have a file that gets dumped into a temp folder. Example file name testimageYYMMDDHHMMSS.JPG, what I am trying to do is a foreach loop that will automate moving it to the new location within the same FTP directory, which the new location folder and subfolder will have; 1 folder for the year,12 folder for the months, 31 folder for the days of the weeks, with 4 time of day folders in each day of the week (every 6 hours 0000,0600,1200,1800).

Thanks in advance
Posted
Comments
PIEBALDconsult 28-Jul-14 22:31pm    
Seems easy enough. So what problem do you have?
@SkyHigh34 28-Jul-14 22:36pm    
I am very new to this and would appreciate some pointing to examples of how to does this.
PIEBALDconsult 28-Jul-14 23:23pm    
http://msdn.microsoft.com/en-us/library/system.io.file.move(v=vs.110).aspx
http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx
@SkyHigh34 30-Jul-14 23:09pm    
I do not get an error but the file does not move?? static void Main(string[] args)
{
string name = "imagenine14073012535800.jpg";
var match = Regex.Match(name, @"(?i)[a-z]+(\d{10})$");

if (match.Success)
{
DateTime dt = DateTime.ParseExact(match.Groups[1].Value, "yyMMddHHmmssff", CultureInfo.InvariantCulture);

string path = string.Format(@"A:\Camera1\{0}\imagenine\{1}\{2}\{3}\{4}",
dt.ToString("yyyy"),
dt.ToString("MMMM"),
dt.ToString("dd"),
dt.ToString("HH00"),
dt.ToString("00mm"));

}
}



???
help; I don't understand how the code would know where to search for the temp file folder and move into the folders named with the time.
PIEBALDconsult 31-Jul-14 0:34am    
So far so good, now call Move.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900