AustinT
AustinT

Reputation: 2026

Where is my FileStream-created file saved?

I am following this tutorial, but I am not where my pdf file is saved to? Thanks for the help!

using System; 
using com.lowagie.text;
using com.lowagie.text.pdf;
using System.IO;

public class Chap0101 
{

public static void Main(string[] args) 
{
    Console.WriteLine("Chapter 1 example 1: Hello World");

    // step 1: creation of a document-object
    Document document = new Document();

    // step 2:
    // we create a writer that listens to the document
    // and directs a PDF-stream to a file
    PdfWriter.getInstance(document, new FileStream("Chap0101.pdf", FileMode.Create));

    // step 3: we open the document
    document.open();

    // step 4: we add a paragraph to the document
    document.add(new Paragraph("Hello World"));

    // step 5: we close the document
    document.close();
}
}

Upvotes: 1

Views: 3342

Answers (2)

Nikola Anusev
Nikola Anusev

Reputation: 7088

It will be in a working directory of your executable, i.e. next to it. If you ran this from Visual Studio, look into projectDirectory\bin\Debug.

Upvotes: 1

Kelsey
Kelsey

Reputation: 47736

It is probably saving the the default location that Visual Studio is specifying.

You should change your FileStream statement to define the location:

PdfWriter.getInstance(document, new FileStream("c:\\Chap0101.pdf", FileMode.Create));

Visual Studio defaults can be modified but most likely look in (assuming 2010):

\Users\{yourUsername}\Documents\Visual Studio 2010\...\bin\Debug

Upvotes: 2

Related Questions