我正在编写代码以找出丢失的数据以及不匹配的位置或不匹配的位置。
有3种情况。
我已经使用else if编写了一个代码,并且我只能捕获两种情况
我如何对两种负面情况进行分类 (ie)此代码中数据库中存在但服务器中不存在的图像(负)和服务器中数据库中存在但不存在(负)的图像
namespace DataTableColumnCommaSeperated
{
class Program
{
static void Main(string[] args)
{
fileOperation();
}
private static void fileOperation()
{
try
{
string main_directory = @"D:\DMSArchivalPhase1\";//src_directory location
string[] lead_list = File.ReadAllLines(main_directory + @"list.txt");//first input
string[] image_list = File.ReadAllLines(main_directory + @"image_list.txt");//image name as per DB
foreach(string lead_id in lead_list)
{
Console.WriteLine(lead_id);
string[] src_list = File.ReadAllLines(main_directory + @"src_list.txt");
foreach (string src_dir in src_list)
{
string final_path = src_dir + lead_id;
if (Directory.Exists(final_path))
{
var filePaths = Directory.GetFiles(final_path, "*.*", SearchOption.AllDirectories).Where(name => !name.EndsWith(".gz"));//images present as per server
foreach (string path in filePaths)
{
FileInfo f = new FileInfo(path);
string strNewName = Path.GetFileNameWithoutExtension(f.Name);
if (Array.Exists(image_list, element => element == strNewName))
{
Console.WriteLine("File exist");
}
else if (Array.Exists(image_list, element => element != strNewName))
{
Console.WriteLine(strNewName + "File name doesnot exist in DMS/Databse");
}
}
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}