string[] folderPaths = new[]
{
"anim",
"audio",
"cleo",
"custom_models",
"data",
"libraries",
"models",
"modloader",
"movies",
"SAMP",
"text"
};
foreach (var folderPath in folderPaths)
{
string[] Liste = Directory.GetDirectories(gameFolder);
foreach (var item in Liste)
{
if (Directory.Exists(folderPath item))
{
MessageBox.Show("All granted folders detected, you can join.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
MessageBox.Show("A not granted folder has been detected, you cant join.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
Although there is all granted folder, I get the same error: "A not granted folder has been detected, you cant join."
CodePudding user response:
I think it would be :
if (Directory.Exists(item "\\" folderPath))
This line string[] Liste = Directory.GetDirectories(gameFolder);
will return directories with full path like C:\\TEMP\\Publish
and you have just the folder name in folderPath
variable.
Here is the full suggested code :
string[] folderNames = new[]
{
"anim",
"audio",
"cleo",
"custom_models",
"data",
"libraries",
"models",
"modloader",
"movies",
"SAMP",
"text"
};
string gameFolder = @"D:\gta san andreas\";
foreach (var folderName in folderNames)
{
if (Directory.Exists(gameFolder folderName))
MessageBox.Show(folderName " Exists");
else
MessageBox.Show(folderName " Not Exists");
}