المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Threads



C# Programming
08-28-2009, 03:10 PM
Hello All ,

I have requirement that User will have list of Directories . the moment user selects a Directory
Thread s hould be started and It s hould display List of Txt files name and dates in Grid .

User can change the directory and the thread should show the files of that directory in grid

I have done the code like this


public static DataTable GetFilesinDirectory()
{
DriveInfo Drive = new DriveInfo(strDriveName);

DirectoryInfo[] DirectoryList =Drive.RootDirectory.GetDirectories(strDirectoryName);


DtFilesList.Rows.Clear();
// DtFilesList.AcceptChanges();
FileInfo[] FilesList = DirectoryList[0].GetFiles("*.txt");

foreach(FileInfo ObjInfo in FilesList)
{
DataRow drFileInfo = DtFilesList.NewRow();

drFileInfo["Name"]=ObjInfo.Name;
drFileInfo["CreationTime"]=ObjInfo.CreationTime;
drFileInfo["Extension"]=ObjInfo.Extension;
drFileInfo["LastWriteTime"]=ObjInfo.LastWriteTime;

DtFilesList.Rows.Add(drFileInfo);
}
return DtFilesList;

}

This method is assigned to thread

strDirectoryName will be updated once user selects the Directory

But problem is Since it is Static method I cant acces the Grid then how should i Bind ?