未定义的路径i变量c#visual studio

未定义的路径i变量c#visual studio,c#,visual-studio-2015,C#,Visual Studio 2015,我找不到变量中未定义路径的位置。调试时,我会在表达式中看到路径名 我怎样才能改变这个 以下是我代码的一部分: private static string getPDFfilename(document theDoc) { string fullPathFilename = theDoc.MultiPagePdfFile; string filenameWithoutPath = Path.GetFileName(fullPathFi

我找不到变量中未定义路径的位置。调试时,我会在表达式中看到路径名

我怎样才能改变这个

以下是我代码的一部分:

private static string getPDFfilename(document theDoc)
        {

           string fullPathFilename = theDoc.MultiPagePdfFile;
            string filenameWithoutPath = Path.GetFileName(fullPathFilename);
            return filenameWithoutPath;


        }


        private static byte[] getEmbbeddedObj(document theDoc)
        {

                string filenameWithoutPath = theDoc.MultiPagePdfFile;
                byte[] bytes = File.ReadAllBytes(filenameWithoutPath);


                return bytes;

       }
错误

theDoc.MultiPagePdfFile=“E:\Ephesoft\final drop folder\decorine\BI1450\LINDER SA_86846_DOC1.pdf”

filenameWithoutPath=“E:\Ephesoft\final drop folder\decorine\BI1450\LINDER SA_86846_DOC1.pdf”


基于变量名“filenameWithoutPath”,您的文件名没有路径。如果为true,请在System.IO命名空间中使用FileInfo。

将其更改为执行什么操作?你想在这里实现什么?在第二种方法中,调用变量filenameWithoutPath,但它只是来自DOC对象的完整路径(糟糕的名称btw)。然而,首先调用Path.GetFileName()以获得“filenameWithoutPath”。这是你的问题吗?你做了一个
字符串文件名,不带outpath=theDoc.MultiPagePdfFile,而不实际调用
getPDFfilename()
函数
Path.GetFileName()
本身应该可以正常工作。是的。。。您实际上没有调用
getPDFfilename()