Click here to Skip to main content
15,911,030 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
public void InsertData(List<string> str)
{
using (var DataEntities = new DataEntities())
{
foreach (string data in str)
{
//var dataArray = data.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);

string filename = Path.GetFileName(dataFileName);

DataFile dataFile = dataEntities.DataFiles.Where(f => f.FilePath == DataFileName).FirstOrDefault();
}
}
}


I have filenames in list (list<string> str).How to get filename from list.
Posted
Updated 22-Feb-15 23:26pm
v2
Comments
stibee 23-Feb-15 5:23am    
for what do you use "dataArray"?
Rnshanmugavadivel 23-Feb-15 5:25am    
Sorry.. That line is existing code. So please comment that line...
stibee 23-Feb-15 5:27am    
For me it's still not clear what you like to do? Find the file inside a list with a specific name?
Rnshanmugavadivel 23-Feb-15 5:33am    
Yes i have lot of filenames in list. some time it comes same file name (mac address as file name) with different date. So we find that same file names..
(Filename Ex : 00171281292a-2014-12-11-2026.txt )
Leo Chapiro 23-Feb-15 5:31am    
>For me it's still not clear what you like to do?
For me too :(

Hi,

As your list is a string type and you want to search the string inside the string list you can able to use something like this:

XML
List<ListBox> list;
            string fileName = list.FirstOrDefault(x => x.Name.Equals("something"));


Here I have used the "Equals()" method to compare the value but you can able to use some more methods like "EndsWith()" or "StartsWith()" etc.

Thanks
Sisir Patro
 
Share this answer
 
You can try this to get filename from your list-

C#
foreach (string data in str)
    {
        string filename=data;
    }
 
Share this answer
 

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