使用visual basic 2010中的“System.IO”从路径中删除文本文件

时间:2013-10-23 15:45:52

标签: vb.net vb.net-2010 system.io.fileinfo

我有这段代码:

Dim WriterDay1 As New System.IO.StreamWriter("C:\Users\IOSEagle\Desktop\My Projects\Microsoft Visual Basic 2010\Form\Programes\MyAlarm\MyAlarm\RepeatDays\Monday.txt")
WriterDay1.Write(MondayCheckBox.Text)
WriterDay1.Close()

如何从此路径中删除此文本文件?

1 个答案:

答案 0 :(得分:3)

你可以做这样的事情来获得路径:

Dim fullPath as String = ((FileStream)(WriterDay1.BaseStream)).Name

然后在文件关闭后删除该文件:

File.Delete(fullPath)