开发者

How to create a file on server and save it on server

I m creating a pdf file on the server using iTextSharp. It is working fine prompting me to save everything is fine. I have 2 scenario 1) I want to save this file on a location on server 2) I want to save this file in database

My Last line after finishing the code is

document.Close();

So can anyone guide me how can I do开发者_如何学运维 it


The following method will create a new file on the disk with a paragraph in it. You could easily modify it to your needs.

Before this will work you must ensue the directory you wish to save to has the correct permissions set. Whatever user account the Application Pool for the website is using will need write access to the folder. Set this in Windows Explorer, Right Click > Properties > Security Tab. This is well documented on the internet.

You can store the filename in the database in many different ways and then link to the file from your UI. I suggest starting with a simple ADO.Net tutorial

protected void CreateDoc(string filename)
{
    Document document = new Document();
    PdfWriter.GetInstance(document, new FileStream(filename, FileMode.Create));

    document.Open();
    document.Add(new Paragraph("Hello World!")); 
    document.Close();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜