System.UnauthorizedAccessException:拒绝访问文件c#

时间:2016-11-15 19:28:17

标签: c#

我在Selenium Grid上运行我的selenium脚本,我偶然发现了这个错误:

    Result Message: 
Test method AutFramework1.Tests.Smoke.RunTest threw exception: 
System.UnauthorizedAccessException: Access to the path 'C:\Users\documents\visual studio 2013\Projects\AutFramework1\AutFramework\Config\SEL_ADAccountReactivate.xml' is denied.
Result StackTrace:  
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, Boolean checkHost)
   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, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync)
   at System.Xml.XmlWriterSettings.CreateWriter(String outputFileName)
   at System.Xml.XmlWriter.Create(String outputFileName, XmlWriterSettings settings)
   at System.Xml.Linq.XDocument.Save(String fileName, SaveOptions options)
   at System.Xml.Linq.XDocument.Save(String fileName)
   at AutFramework1.Helpers.ReportSample.InsertValues(String ID, String Screenshot, String Step, String Result, String Comment) in c:\Users\Documents\Visual Studio 2013\Projects\AutFramework1\AutFramework\Helpers\ReportSample.cs:line 63

我已经编写了一个c#来将所有结果写入此xml文件,但它不允许我这样做。我已经调整了文件安全设置。我现在不知道该怎么做,我需要用我的代码做些什么吗?感谢

1 个答案:

答案 0 :(得分:1)

必须检查proc explorer并且我的文件中还有一些内容。问题已解决。谢谢你们的投入