I'm getting the IOException
Error when I try this, and I'm not sure what I'm doing wrong:
This is my code:
FileStream fStream = new FileStream(PDFFilePath(), FileMode.CreateNew, FileAccess.ReadWrite);
Where
private string PDFFilePath()
{
m_sFilePath = "C:/Pictures/";
return m_sFilePath;
}
What am I missing?
I'm using this FileStream
to save PDF documents using the Pdf.Select NuGet. It uses a method:
PdfDocument.Save(Stream stream);
I think you should be specifying your path this way:
private string PDFFilePath(string filename)
{
m_sFilePath = @"C:\Pictures\" + filename;
return m_sFilePath;
}
Like @Reisclef said, you have to provide a file path, not a directory. Since you're using FileMode.CreateNew
, it has to be a new file, so you might also want to use File.Exists(m_sFilePath)
before returning.