C# 传递文件路径的WCF服务

C# 传递文件路径的WCF服务,c#,wcf,C#,Wcf,在我的WCF中,我接受一个参数Filepath 即。 F:\BatchFiles\InputFile\SampeFile\u Tabbed\u with null.txt(此文件100%存在) 那么我有这张支票 public BatchSplitterResponse SplitFile(BatchSplitterRequest request) { //Retrieve File var response = new BatchS

在我的WCF中,我接受一个参数Filepath

即。 F:\BatchFiles\InputFile\SampeFile\u Tabbed\u with null.txt(此文件100%存在)

那么我有这张支票

public BatchSplitterResponse SplitFile(BatchSplitterRequest request)
        {
            //Retrieve File
            var response = new BatchSplitterResponse();
            if (request != null)
            {
                var filePath = request.FilePath;
                var numberOfRecordsPerFile = request.NumberOfRecordsPerFile;

                if (File.Exists(filePath))
                {..
}
当我将我的WCF作为服务引用添加到控制台应用程序并调用我的WCF服务时,我不断收到一个错误,即该文件不存在

var linkService = new BatchSplitterClient("BasicHttpBinding_IBatchSplitter");
var response = linkService.SplitFile(new BatchSplitterRequest(){FilePath = @"F:\BatchFiles\InputFile\SampeFile_Tabbed_WithNull.txt",NumberOfRecordsPerFile = 1000});

我遗漏了什么吗?

运行WCF服务的用户可能无法访问“F:\”驱动器。这可能是因为它是一个已装入的驱动器,或者缺少/不正确的权限。

您的问题可能在于应用程序池标识。 您需要将applicationpool设置为“ApplicationPoolIdentity”

这里有一个链接,可以解释更多关于这个主题的内容。

您能在WCF服务中记录路径并检查其是否有效吗?您的WCF服务是否托管在IIS中?我们不知道@StevieB是否使用托管在IIS或控制台应用程序中的服务。也许问这个问题是个好主意!