我正在尝试确定以下3个位置中的任何一个是否可访问并追加到构建位置,如果可访问多个位置,请选择其中一个并在没有退出的情况下纾困,谁能提供有关如何执行此操作的信息?

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

        }
    }
}

最佳答案

也许是这样的?

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.
}

关于c# - 如何检查位置是否可访问并附加到位置,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39483268/

10-09 06:54
查看更多