Vb.Net未经授权的访问异常

编程入门 行业动态 更新时间:2024-10-13 06:15:10
本文介绍了Vb.Net未经授权的访问异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好, 我一直在尝试编写一个使用OpenXML docmentformat生成Word文档的小程序。 在我的mainform中,我有一个创建文档的方法:

Hello, I have been trying to write a small program that generates a Word document using OpenXML docmentformat. In my mainform I have a method creating the document:

' Creates a WordprocessingDocument. Public Sub CreatePackage(filePath As String, text As String) Using package As WordprocessingDocument = WordprocessingDocument.Create(_filename, WordprocessingDocumentType.Document) ' Add a new main document part. package.AddMainDocumentPart() ' Create the Document DOM. package.MainDocumentPart.Document = New Document(New Body(New Paragraph(New Run(New Text(text))))) ' Save changes to the main document part. package.MainDocumentPart.Document.Save() End Using End Sub

当我运行程序时,我得到一个UnauthorizedAccessException访问路径'C:\ Temp'被拒绝。 我试过搜索网但是有51.000次点击这基本上不可能全部审查。我的安排和迄今为止我检查的内容: * Windows 7 Pro * Visual Studio 2010(以管理员身份运行) *我有PC上的管理员权限 *尝试使用

When I run the program I get a "UnauthorizedAccessException" Access to the path 'C:\Temp' is denied. I have tried searching the net but with 51.000 hits on this basically impossible to review them all. My settup and what I have checked so far: * Windows 7 Pro * Visual Studio 2010 (running as admin) * I have admin rights on PC * tried to add a app.manifest with

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

任何帮助都会赞赏。

Any help would appreciated.

推荐答案

我猜C:\ Temp是一个现有的文件夹,并希望您正确设置访问权限 - 因此C:\ Temp不是文件的可接受名称。 我看到你的函数使用 CreatePackage(filePath As String ,而你调用 WordprocessingDocument.Create(_filename 。您是否混淆了文件名?在您具有写入权限的文件夹中尝试不存在的文件名。 I guess C:\Temp is an existing folder, and hopefully you set the access rights correctly - hence C:\Temp is not an acceptable name for a file. I see that your function uses CreatePackage(filePath As String while the you call WordprocessingDocument.Create(_filename. Did you mix up the filenames? Try a non-existing filename in a folder where you have write access.

更多推荐

Vb.Net未经授权的访问异常

本文发布于:2023-11-11 05:33:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1577522.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:未经授权   异常   Vb   Net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!