上传后,Upoladed文件已损坏

时间:2016-10-05 10:54:41

标签: c# asp.net

我的网络应用程序出了问题。我已经上传了上传文件的功能。一个用于答案纸,另一个用于问题文件。我没有问题在问题Papeer它的工作正常,但在上传后答案纸是腐败的..

任何Idia

<div >
                  <label class="control-label" for="fileInput">Attached Question File </label>
                  <div class="controls">
                    <asp:FileUpload ID="fuQFile" runat="server" onChange="chngFUvalue(this)" CssClass="input-file uniform_on" />
                    &nbsp;&nbsp;<asp:Label ID="lblQVfile" runat="server" Text=""></asp:Label></div>
                </div>
                   <div class="control-group">
                  <label class="control-label" for="fileInput">Attached Answer File </label>
                  <div class="controls">
                    <asp:FileUpload ID="fuAFile" runat="server" onChange="chngFUvalue(this)" CssClass="input-file uniform_on" />
                    &nbsp;&nbsp;<asp:Label ID="lblAVfile" runat="server" Text=""></asp:Label></div>
                </div>

/// For Question Pappr(Works Fine)////                 string VQFile =“”,VQFilePath =“”;

            if (fuQFile.HasFile)
            {
                VQFile =  fuQFile.FileName.ToString();
                VQFilePath = "1upload/files/Question/" + VQFile;
                fuQFile.SaveAs(Server.MapPath("~/1upload/files/Question/") + VQFile);
            }
            else
            {
                VQFilePath = lblQVfile.Text;

            }



      // For Answer Paper(Facing Problem With That Part)////File Is Corrupt After Upload//////
            if (fuAFile.HasFile)
            {
                VAFile = rndnom + "-" + fuAFile.FileName.ToString();
                VAFilePath = "1upload/files/Answer/" + VAFile;
                fuQFile.SaveAs(Server.MapPath("~/1upload/files/Answer/") + VAFile);
            }
            else
            {

                VAFilePath = lblAVfile.Text;
            }

1 个答案:

答案 0 :(得分:1)

您在保存答案文件时调用fuQFile.SaveAs,而不是fuAFile.SaveAs。

enter image description here