C# 在iis上托管时未找到目录异常
我有一个web服务,它从服务器呈现PDF并将其转换为字节流 我遇到的问题是,当托管在IIS上时,web方法不起作用,我不知道可能是什么问题,因为我不在c#。我只想要它的响应,需要在我的android应用程序中显示。我得到的错误是: System.IO.DirectoryNotFoundException:找不到路径“D:\VAT Publishing\Android\u web\u service\App\u Data\Order\u Copy\303900816\u Appl\u Application.pdf”的一部分。 在System.IO.\uuu Error.WinIOError(Int32 errorCode,字符串maybeFullPath) 在System.IO.FileStream.Init(字符串路径、文件模式、文件访问权限、Int32权限、布尔用户权限、文件共享、Int32缓冲大小、文件选项选项、安全属性secAttrs、字符串msgPath、布尔bFromProxy、布尔useLongPath) 位于System.IO.FileStream..ctor(字符串路径、文件模式、文件访问权限、文件共享、Int32 bufferSize、文件选项选项、字符串msgPath、布尔bFromProxy) 位于System.IO.FileStream..ctor(字符串路径、文件模式、文件访问访问、文件共享) at officer_auth.GetFile(字符串文件名) 我的代码如下C# 在iis上托管时未找到目录异常,c#,asp.net,.net,webmethod,C#,Asp.net,.net,Webmethod,我有一个web服务,它从服务器呈现PDF并将其转换为字节流 我遇到的问题是,当托管在IIS上时,web方法不起作用,我不知道可能是什么问题,因为我不在c#。我只想要它的响应,需要在我的android应用程序中显示。我得到的错误是: System.IO.DirectoryNotFoundException:找不到路径“D:\VAT Publishing\Android\u web\u service\App\u Data\Order\u Copy\303900816\u Appl\u Applic
public byte[] GetFile(string filename)
{
// byte[] binFile = new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };
string src = "\\\\182.10.0.10\\d$\\abc_Files\\" + filename.ToString();
string dest = Server.MapPath("~/App_Data/Order_Copy/") + "\\" + filename.ToString();
FileInfo theFile = new FileInfo(src);
try
{
foreach (string file1 in Directory.GetFiles(Server.MapPath("~/App_Data/Order_Copy/"), "*.pdf"))
{
try { File.Delete(file1); }
catch { }
}
}
catch
{ }
if (theFile.Exists)
{
File.Copy(src, dest);
}
BinaryReader binReader = new BinaryReader(File.Open(Server.MapPath("~/App_Data/Order_Copy/") + "\\" + filename.ToString(), FileMode.Open, FileAccess.Read));
binReader.BaseStream.Position = 0;
byte[] binFile = binReader.ReadBytes(Convert.ToInt32(binReader.BaseStream.Length));
binReader.Close();
return binFile;
}
该异常在何处引发?在输入文件名并单击“调用”按钮后,我得到以下异常..我的意思是,您能指出代码示例中的确切行吗?当我通过visual Basic运行代码时,代码运行良好,它为我提供了所需的输出..但当我尝试在iis上托管它时,它提供了一个例外情况…您确定
D:\VAT Publishing\Android\u web\u service\App\u Data\Order\u Copy\303900816\u Appl\u Application.pdf
存在吗?