서버에 파일 경로가 있는지 확인하여 작업 할 수 있는지 확인하려고합니다. 현재 테스트 목적으로 localhost를 서버로 사용하고 있습니다. if (File.Exists(filePath1))
경로를 찾았지만 서버에 액세스하지 않고 로컬로 파일을 찾습니다.parm 값을 사용하여 파일이 존재하는지 어떻게 확인합니까?
에 filePath1
이 있는지 어떻게 확인할 수 있습니까? 솔루션을 배포하기 전에 다음 매개 변수 값을 사용하여 테스트하고 있습니다. 클래스 ParmNames에서
매개 변수 값 :
filePath1 = "C:\\Users\\smithj\\Documents\\file.txt"
server1 = "localhost"
public class class1
{
FileRules putFileRH = new FileRules();
List<IRuleParameter> FileParms = new List<IRuleParameter>();
private bool Method1()
{
FileParms.Add(new RuleParms(ParmNames.SourceServer, server1.ToString(), string.Empty));
FileParms.Add(new RuleParms(ParmNames.FileName, filePath1, string.Empty));
foreach (var server in FileParms) //not sure if this actually goes through each server or through each parm in FileParms
{
//if (File.Exists(filePath1)) first attempt
if (File.Exists(server.ValueEnvironment)) //this attempt doesn't find the file
{
...
return true;
}
else
{
...
return false;
}
return true;
}
}
}
IRuleParameter 인터페이스 :
여기public interface IRuleParameter
{
string Name { get; }
string ValueEnvironment { get; }
string ValueType { get; }
}
같은 (문제에 관련된 모든 조각을 보여줍니다 최소한의 코드를 입력하십시오 'IRuleParameter') –