Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 有没有办法在没有文件上传的情况下附加文件?_C#_Sql_Asp.net_File Upload - Fatal编程技术网

C# 有没有办法在没有文件上传的情况下附加文件?

C# 有没有办法在没有文件上传的情况下附加文件?,c#,sql,asp.net,file-upload,C#,Sql,Asp.net,File Upload,我加密了一个pdf,并想将其保存到数据库中,下面是我如何加密的代码。我想知道是否有任何方法可以在不使用文件上传程序的情况下将创建的“PDFEncrypted.pdf”设置到流fs中 string WorkingFolder = Server.MapPath("~/Files/"); string InputFile = Path.Combine(WorkingFolder, "PDF.pdf"); string OutputFile = Path.Com

我加密了一个pdf,并想将其保存到数据库中,下面是我如何加密的代码。我想知道是否有任何方法可以在不使用文件上传程序的情况下将创建的“PDFEncrypted.pdf”设置到流fs中

     string WorkingFolder = Server.MapPath("~/Files/");
        string InputFile = Path.Combine(WorkingFolder, "PDF.pdf");
        string OutputFile = Path.Combine(WorkingFolder, "PDFEncrypted.pdf");

        using (Stream input = new FileStream(InputFile, FileMode.Open, FileAccess.Read, FileShare.Read))
        {
            using (Stream output = new FileStream(OutputFile, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                PdfReader reader = new PdfReader(InputFile);
              PdfEncryptor.Encrypt(reader, output, true, "pass123", "secret", PdfWriter.ALLOW_SCREENREADERS);
            }
        }
所以我有这些代码来上传

Stream fs = FileUpload1.PostedFile.InputStream;
BinaryReader br = new BinaryReader(fs);
Byte[] bytes = br.ReadBytes((Int32)fs.Length);