简体   繁体   中英

WCF Service passing a filepath

In my WCF I accept a parameter Filepath

Ie F:\\BatchFiles\\InputFile\\SampeFile_Tabbed_WithNull.txt (This file 100% exists)

And I have this check then

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

When I add my WCF as a service reference to my console application and call my WCF service I keep getting an error that the file does not exist..

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

Am I missing something ?

The user that is running your WCF service probably doesn't have access to the the "F:\\" drive. This could be because it is a mounted drive or some missing/incorrect permission.

Your problem my be in the applicationpool identity. You need to set up your applicationpool to "ApplicationPoolIdentity"

Here is a link that explains a bit more about the subject. http://www.iis.net/learn/manage/configuring-security/application-pool-identities

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM