SoFunction
Updated on 2025-03-08

C# Method to obtain files in the specified directory of the project

This article describes the method of obtaining files in the specified directory of the project in C#. Share it for your reference. The details are as follows:

public List<FileInfo> GetFiles() {
  string path = (,"Files\\"); 
  //Get the physical path of the project  string[] fileType=new string[]{"pdf\\","pps\\","xls\\"};
  string[] directoryFiles = new string[] { };
  List<FileInfo> fileInfoList = new List<FileInfo>();
  for (int f = 0; f < (); f++) {
   path = path + fileType[f];
   directoryFiles=(path);
  for(int d=0;d<();d++){
   FileInfo fileInfo = new FileInfo(directoryFiles[d]);
   (fileInfo);
   }
  }
  return fileInfoList;
}

silverlight gets xap path:

I hope this article will be helpful to everyone's C# programming.