kemosabee kemosabee - 2 months ago 16
C# Question

how to check for location is accessible and append to location

I am trying to figure out if any of the below 3 locations are accessible and append to build location,if multiple locations are accessible pick one of them and bail out if none exit,can anyone provide info on how to do this?

1.BIN-LOC-WiFi-FW\loc_proc\bin

2.loc_proc\pkg\cnss_proc\bin

3.loc_proc_ps\package

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace aputloader
{
class Program
{
static void Main(string[] args)
{
string buildlocation = @"\\location\builds784\INTEGRATION\LOC.1.2-00028-Z-1";
//check if atleast one of the following folders exist and append to buildlocation

//1.BIN-LOC-WiFi-FW\loc_proc\bin
//2.loc_proc\pkg\cnss_proc\bin
//3.loc_proc_ps\package
//multiple folders exist ,pick one
//none exist ,bail out

}
}
}

Answer

Maybe something like this?

if(Directory.Exists("BIN-LOC-WiFi-FW\loc_proc\bin")) 
{
    // This path is a directory

}
Else if(Directory.Exists("loc_proc\pkg\cnss_proc\bin")) 
{
    // This path is a directory

}
Else if(Directory.Exists("loc_proc_ps\package") 
{
    // This path is a directory

}
else 
{
    Console.WriteLine("No valid folder exists.");
    // Do nothing.
}        
Comments