尝试使用以下代码编写PDF文档:
document = new Document();
PdfWriter writer = null; ;
try
{
writer = PdfWriter.GetInstance(document, new FileStream(@"E:\mergFiles", FileMode.Create));
}
catch (Exception xc)
{ }
我遇到了一个异常:
{System.UnauthorizedAccessException: Access to the path 'E:\mergFiles' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)
at PDFLibrary.PDFManager.MergeDocs()}
我对这个文件夹拥有完全访问权限。
我搜索了一下并发现这个命令可能有用:File.SetAttributes(@"E:\mergFiles", FileAttributes.Normal);
但是依旧出现相同的异常。
Path
类中的帮助程序创建路径... - Alexei Levenkov