Click here to Skip to main content
15,923,015 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Folder of *.swf files.i have to get the fileInformation in to List.Here in below i have created an object,when i am adding into the list it returns null details only.I coudn't find where i have done the mistae.Help me in this
public List<Course> FileInfoSelected(string pathFolder)
    {
        List<Course> courses = new List<Course>();
        string FilePath="C:\\magnil\\Gavas\\"+pathFolder;
        DirectoryInfo dir = new DirectoryInfo(FilePath);
        FileInfo[] filedetails = dir.GetFiles("*.swf");
        foreach (FileInfo FI in filedetails)
        {
            courses.Add(new Course(FI.Name, FI.Length,FI.LastAccessTime));
        }
        return courses;
    }
Posted

FileInfo[] filedetails = dir.GetFiles("*.swf");


By putting debug point make sure that you are getting filedetails.

courses.Add(new Course(FI.Name, FI.Length,FI.LastAccessTime));


For this make sure your Class Course having constructor with three args,
and also you have used public property for those parameters,
So that it can be accessed and inside the constructer you are initializing the value of those parameter so that it doesn't get NULL values.

Please vote and Accept Answer if it Helped.
 
Share this answer
 
Comments
Nettai 6-Oct-10 2:06am    
thanks for the reply..i have done the mistake in the course constructor...now i corrected it..
The List object adds only one single value at a time by default.But, Here You are using the Course Class in that take three properties like {string int,date time } after that u can able to add the values.
 
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