EDN Admin
Well-known member
Hi all,
I am trying to get the information of files ending in .eps from two different locations and write the file names to two seperate .txt files. And the masterLocation is a folder that only has other folders in that need searching and the subLocation only has files in the folder. Here is my code so far:namespace folderFileFinder_v1
{
class Program
{
static void Main(string[] args)
{
try
{
//Create variables for file paths
string masterLocation = (@"E:aBULKProjects_Chartbook_ChBkArt");
string subLocation = (@"B:FundRepFMP10MiFIDChBkArt_MiFID");
//Create variables for type of files to look for
DriveInfo di = new DriveInfo(masterLocation);
DirectoryInfo dirInfo = di.RootDirectory;
FileInfo[] fileNames = dirInfo.GetFiles("*.eps");
Console.WriteLine("Files found at {0}n", masterLocation);
//Loop through each of the files found and print their names in the console
foreach (FileInfo fi in fileNames)
{
Console.WriteLine("{0}", fi.Name);
}
//Copy names of the files into a new .txt file
File.WriteAllLines(masterLocation, fileNames.Select(fi => fi.Name));
File.WriteAllLines(subLocation, fileNames.Select(fi => fi.Name));
Console.WriteLine("n");
}
//If fails
catch (IOException ioex)
{
Console.WriteLine(ioex);
}
}
}
}
But it doesnt seem to look in the file path as stated in the variables I have created ie
masterLocation and subLocation
It is only looking in the roots ie B: and E:
Any ideas?
Lee Warren
View the full article
I am trying to get the information of files ending in .eps from two different locations and write the file names to two seperate .txt files. And the masterLocation is a folder that only has other folders in that need searching and the subLocation only has files in the folder. Here is my code so far:namespace folderFileFinder_v1
{
class Program
{
static void Main(string[] args)
{
try
{
//Create variables for file paths
string masterLocation = (@"E:aBULKProjects_Chartbook_ChBkArt");
string subLocation = (@"B:FundRepFMP10MiFIDChBkArt_MiFID");
//Create variables for type of files to look for
DriveInfo di = new DriveInfo(masterLocation);
DirectoryInfo dirInfo = di.RootDirectory;
FileInfo[] fileNames = dirInfo.GetFiles("*.eps");
Console.WriteLine("Files found at {0}n", masterLocation);
//Loop through each of the files found and print their names in the console
foreach (FileInfo fi in fileNames)
{
Console.WriteLine("{0}", fi.Name);
}
//Copy names of the files into a new .txt file
File.WriteAllLines(masterLocation, fileNames.Select(fi => fi.Name));
File.WriteAllLines(subLocation, fileNames.Select(fi => fi.Name));
Console.WriteLine("n");
}
//If fails
catch (IOException ioex)
{
Console.WriteLine(ioex);
}
}
}
}
But it doesnt seem to look in the file path as stated in the variables I have created ie
masterLocation and subLocation
It is only looking in the roots ie B: and E:
Any ideas?
Lee Warren
View the full article