1.Sorry不知道你的環境是VB.Net,上述語法是VB6環境下執行的
2. R.Length < 10 和 size < 10 應該都可以
3.Console.WriteLine(Size + "小於" + Apath) 應該不會寫入文字檔
4.底下是MSDN寫入文字檔的範例,請參考修改:
Option Explicit On
Option Strict On
Imports System
Imports System.IO
Public Class TextToFile
Private Const FILE_NAME As String = "MyFile.txt"
Public Shared Sub Main()
If File.Exists(FILE_NAME) Then
Console.WriteLine("{0} already exists.", FILE_NAME)
Return
End If
Using sw As StreamWriter = File.CreateText(FILE_NAME)
sw.WriteLine("This is my file.")
sw.WriteLine("I can write ints {0} or floats {1}, and so on.", 1, 4.2)
sw.Close()
End Using
End Sub
End Class作者: webbliu 時間: 2011-8-6 12:06
If File.Exists(path) Then '如果檔案存在
If File.Length < 10 Then '隨便你要加什麼程式碼
Else
End If
Else '如果檔案不存在
Using atxt As StreamWriter = File.CreateText("C:\exists.txt") '開檔
atxt .WriteLine("下列檔案不存在:" ) '寫入一行
atxt .WriteLine(path) '寫入不存在的檔案路徑
atxt .Close() '關閉檔案
End Using
End If