开发者

VB 2010 mkdir read only

Hi i cant seem to get mkdir to create a folder which isnt read only, this is causing alot of problems in my code because i am unable to write files to the directory i have created. thanks for any help. this is my code below:

Else

    MessageBox.Show("Please set a Root Path for your ****")
    RootFBD.ShowDialog()
    TextBox1.Text = RootFBD.SelectedPath
    My.Computer.FileSystem.CreateDirectory("C:\****-Tools\config\root.txt")
 End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim f2 As New FileIOPermission(FileIOPermissionAccess.Read, TextBox1.Text)
    f2.AddPathList(FileIOPermissionAccess.Write Or FileIOPermissionAccess.Read, TextBox1.Text)

    Dim rootSave As System.IO.StreamWriter
    rootSave = My.Computer.FileS开发者_如何学Pythonystem.OpenTextFileWriter("C:\****-Tools\config\root.txt", True)
    rootSave.WriteLine(TextBox1.Text)
    Me.Hide()
    MainTool.Show()
End Sub
End Class

Thanks again josh


You're misunderstanding the problem; this isn't a permission issue.
Rather, you're leaving the file open, which prevents other processes from writing to ir.

You just need to Close() your StreamWriter.

Or, you can just call File.AppendText, which will avoid the issue.


You are creating the directory with the file name. Try this:

My.Computer.FileSystem.CreateDirectory("C:\****-Tools\config")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜