Abhilash J A

Abhilash J A

  • 537
  • 2.4k
  • 597k

How to save each ArrayList value?

Oct 4 2016 8:32 PM
Hello Everyone,
 
I am trying to each save filepath and filename from Arralist.
In the 'Images' folder have 3 .jpg file. Like that, 'E:\File\Images\A_001.jpg' , E:\File\Images\A_002.jpg ect. I want to save each filepath and
filename (A_001), here 'A' is parrentName and childName is 001,002 ect. childName want to save under the parrentName. How to save each filepath and filename?
  1. string[] jpgFilePath = Directory.GetFiles(@"E:\File\Images""*.jpg").ToArray();  
  2.   
  3.            string[] jpgFilesNames = Directory.GetFiles(@"E:\File\Images""*.jpg")  
  4.                                            .Select(path => Path.GetFileName(path))  
  5.                                            .ToArray();  
  6.   
  7.   
  8.            objTble_Documents.CreatedDate = Convert.ToDateTime(DateTime.Now);  
  9.            objTble_Documents.IsActive = true;  
  10.            objTble_Documents.CreatedBy = 1;  
  11.            objTble_Documents.UserId = 1;  
  12.            foreach (var item in jpgFilePath)  
  13.            {                 
  14.                foreach (var item1 in jpgFilesNames)  
  15.                {                      
  16.                    string parrentName = item1.Split('_')[0];  
  17.                    string childName = item1.Split('_')[1];  
  18.                    objTble_Documents.FilePath = item;  
  19.                    objTble_Documents.Parent_File_Name = parrentName;  
  20.                    objTble_Documents.Child_File_Name = childName;  
  21.                    service.ObjDocuments = Mapper.Map<ViewModel.Tble_Documents, Tble_Documents>(objTble_Documents);  
  22.                    service.AddScanDocuments();  
  23.                }  
  24.            }  

Answers (6)