level 3
如题。
我开发一个程序。在指定时间由计划任务自动调用运行,运行完成后留下log文件。
但我不知道如何用VB2010创建txt文件。
System.IO.File.WriteAllText和My.Computer.FileSystem.WriteAllText只能写已经存在的txt文件。
vb6用的是Fso对象,但VB2010中已经没有这个对象了。
求达人解惑。谢谢!
2012年10月10日 09点10分
1
level 11
System.IO.File.WirteAllText("\Test.txt","内容")
2012年10月11日 16点10分
2
TKS~~ 我已经处理好了~是我自己的路径设置有问题。不过还是谢谢你~
2012年10月13日 05点10分
level 3
Private Sub cmdCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCreate.Click
Dim intFileNum As Integer = FreeFile()
Dim strFileName As String = "d:\" & Second(Now) & ".txt" FileOpen(intFileNum, strFileName, OpenMode.Output, OpenAccess.Default, OpenShare.Shared, )
Print(intFileNum, Now)
FileClose(intFileNum)
End Sub
2012年10月19日 15点10分
3
level 3
Private Sub cmdCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCreate.Click
Dim intFileNum As Integer = FreeFile()
Dim strFileName As String = "d:\" & Second(Now) & ".txt"
FileOpen(intFileNum, strFileName, OpenMode.Output, OpenAccess.Default, OpenShare.Shared, )
Print(intFileNum, Now)
FileClose(intFileNum)
End Sub
2012年10月19日 15点10分
4
谢谢!已经处理OK了!
2012年10月20日 01点10分
level 9
用streamwriter试试?我记得是可以的,也非常简单。
2012年11月14日 04点11分
5