Sch*_*enz 50
这是一行将创建(或覆盖)文件:
File.Create("C:\my files\2010\SomeFileName.txt").Dispose()
注意:调用Dispose()可确保关闭对文件的引用.
Geo*_*rey 25
您还可能想要检查文件是否已存在以避免意外替换文件(除非理所当然:
Dim filepath as String = "C:\my files\2010\SomeFileName.txt"
If Not System.IO.File.Exists(filepath) Then
   System.IO.File.Create(filepath).Dispose()
End If
小智 5
您可以尝试写入Documents文件夹.这是我为项目的调试需求所做的"调试"功能:
Private Sub writeDebug(ByVal x As String)
    Dim path As String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
    Dim FILE_NAME As String = path & "\mydebug.txt"
    MsgBox(FILE_NAME)
    If System.IO.File.Exists(FILE_NAME) = False Then
        System.IO.File.Create(FILE_NAME).Dispose()
    End If
    Dim objWriter As New System.IO.StreamWriter(FILE_NAME, True)
    objWriter.WriteLine(x)
    objWriter.Close()
End Sub
您可以通过"SpecialFolder"对象访问更多标准文件夹.