0

我的代码我使用streamwriter打开/创建一个文件并写入它。这在调试模式下工作正常,但在运行可执行文件时出现“权限被拒绝”错误。这是下面有问题的代码。

      Left out part of the code in first post, here's the correct snippet:

        Dim DateOfTest As Date
        Dim TesterName As String
        Dim SerialNumber As String

        TesterName = TextBoxTester.Text
        DateOfTest = Now
        SerialNumber = TextBoxBoardSN.Text

        'File writing for test info
        Dim path As String = "C:\" & SerialNumber & ".txt"

        If File.Exists(path) Then
            File.Delete(path)
        End If

        ' Create the file. 
        Dim writer As StreamWriter = New StreamWriter(path)

        writer.WriteLine("CPX Loopback Test " & vbCrLf)
        writer.WriteLine("Serial Number " & vbTab & "Tester Name" & vbTab & "Date")
        writer.WriteLine(SerialNumber & vbTab & vbTab & TesterName & vbTab & vbTab & DateOfTest & vbCrLf)
4

1 回答 1

3

尝试:右键单击=>以管理员身份运行

如果这解决了问题,那是由于 Visual Studio 的权限大于 .exe 的权限

于 2013-08-16T17:57:51.477 回答