In a C# 2008 desktop application I would like to know how to change the following code so that the files I am looking for can be located.
 
The code was written for a directory path that looks like the following:
C:\Trans\01-2013 -Note the 01-2013 is for month and year.
 
Now I am finding out that the file directory stucture in production looks like the following:
R:\Trans\_JAN_2013\A-Sample. Under the A-Sample directory there are 4 separate subdirectories
called: SUB1, SUB2, SUB3, and SUB4.
 
I was expecting to see the files in one directory instead of 4 separate directories.
 
Thus can you show me code and/or tell me how you would change the code to accomodae the change in the file directory strucutre?
	
		
			
		
		
	
				
			
                 string Format_Date = DateTime.Now.AddMonths(-1).ToString("MM-yyyy");
                     String filesaveLocation = null;
                     filesaveLocation = Path.Combine(ConfigurationSettings.AppSettings["tLocation"], Format_Date);
                     if (!Directory.Exists(filesaveLocation))
                     {
                         System.IO.Directory.CreateDirectory(filesaveLocation);
                         logging.Error("The location " + filesaveLocation + " does not exist.");
                         return packageId;
                     }
 
                    else
                     {
                        string[] RFiles = (from path in Directory.GetFiles(filesaveLocation)
                                              let name = Path.GetFileName(path)
                                              where name.EndsWith(".pdf") ||
                                              name.EndsWith(".xlsx") ||
                                              name.EndsWith(".xls")
                                              select path).ToArray();
                        
                      }
                         foreach (String RFile in RFiles)
                       {
                       }
The code was written for a directory path that looks like the following:
C:\Trans\01-2013 -Note the 01-2013 is for month and year.
Now I am finding out that the file directory stucture in production looks like the following:
R:\Trans\_JAN_2013\A-Sample. Under the A-Sample directory there are 4 separate subdirectories
called: SUB1, SUB2, SUB3, and SUB4.
I was expecting to see the files in one directory instead of 4 separate directories.
Thus can you show me code and/or tell me how you would change the code to accomodae the change in the file directory strucutre?
			
				Last edited by a moderator: 
			
		
	
								
								
									
	
		
			
		
		
	
	
	
		
			
		
		
	
								
							
							