我将从客户端上传带有文件上传控制的图像并将其转换为流对象并将其发送到 wcf 服务,此过程与 asp.net 应用程序一起使用,但是当我在 IIS 5.1 中托管此应用程序时上传记录它显示错误为
拒绝访问路径“C:\Documents and Settings\patnayak\Desktop\Temp.xlsx”
在 Google 搜索之后,我授予我系统中对 Temp.xlsx 的 asp.net 用户权限的访问权限,然后它就可以工作了。其他系统如何上传文件。
我的代码:
ClientBOL.CD.CPI2Library objLib = new ClientBOL.CD.CPI2Library();
UDO.CPI2LibraryList libfiles = new UDO.CPI2LibraryList(true, "");
HttpFileCollection hfc = Request.Files;
libfiles.CPI2Libraries = new UDO.CPI2Library[hfc.Count];
for (int i = 0; i < hfc.Count; i++)
{
HttpPostedFile hpf = hfc[i];
if (hpf.ContentLength > 0)
{
libfiles.CPI2Libraries[i] = new UDO.CPI2Library();
libfiles.CPI2Libraries[i].FileName = System.IO.Path.GetFileName(hpf.FileName);
libfiles.CPI2Libraries[i].FiletypeId = GetFileTypeId(System.IO.Path.GetFileName(hpf.FileName));
libfiles.CPI2Libraries[i].DoctypeId = 1;
FileInfo fileInfo = new FileInfo(hpf.FileName);
UDO.UDOFileOperations.RemoteFileInfo ri = new UDO.UDOFileOperations.RemoteFileInfo();
System.IO.FileStream stream = new System.IO.FileStream(hpf.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
ri.FileName = System.IO.Path.GetFileName(hpf.FileName);
ri.Length = fileInfo.Length;
ri.FileByteStream = stream;
ClientBOL.CD.FileOperations cdc = new ClientBOL.CD.FileOperations();
cdc.UploadFile(ri);
}
}