Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
6
Answers
How to save each ArrayList value?
Mani Kandan
8y
291
1
Reply
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?
string
[] jpgFilePath = Directory.GetFiles(@
"E:\File\Images"
,
"*.jpg"
).ToArray();
string
[] jpgFilesNames = Directory.GetFiles(@
"E:\File\Images"
,
"*.jpg"
)
.Select(path => Path.GetFileName(path))
.ToArray();
objTble_Documents.CreatedDate = Convert.ToDateTime(DateTime.Now);
objTble_Documents.IsActive =
true
;
objTble_Documents.CreatedBy = 1;
objTble_Documents.UserId = 1;
foreach
(var item
in
jpgFilePath)
{
foreach
(var item1
in
jpgFilesNames)
{
string
parrentName = item1.Split(
'_'
)[0];
string
childName = item1.Split(
'_'
)[1];
objTble_Documents.FilePath = item;
objTble_Documents.Parent_File_Name = parrentName;
objTble_Documents.Child_File_Name = childName;
service.ObjDocuments = Mapper.Map<ViewModel.Tble_Documents, Tble_Documents>(objTble_Documents);
service.AddScanDocuments();
}
}
Post
Reset
Cancel
Answers (
6
)
Next Recommended Forum
Get permutations of array numbers
How can I extract and save the data of social network in DB?