ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] §PÂ_Àɮצs¦b§_? µ²ªG¬°"False¤£¦s¦b" ªºÀɮ׿é¥X¤å¦rÀÉ®×

¥»©«³Ì«á¥Ñ elinbit ©ó 2011-8-6 07:47 ½s¿è

Dim NotExistFile As String
    Dim TarFile As String
    Dim OpenFileNum As Integer
   
    NotExistFile = "¤U¦CÀɮפ£¦s¦b¡G" & vbCrLf
   
    '¥H¤U§PÂ_½Ð¦Û¦æÅܤÆ
    If Dir("path/fileA") = "" Then NotExistFile = NotExistFile & "path/fileA" & vbCrLf
    If Dir("path/fileB") = "" Then NotExistFile = NotExistFile & "path/fileB" & vbCrLf
    .
    .
    .
    .
        
    TarFile = "D:\Temp\FilesNotExist.txt" '§A·Q¿é¥XÀx¦sªºÀɮצWºÙ¸ô®|
      
    OpenFileNum = FreeFile
    Open TarFile For Output As #OpenFileNum
    Print #OpenFileNum, NotExistFile
    Close #OpenFileNum
BOB

TOP

¦^´_ 5# webbliu


    1.Sorry¤£ª¾¹D§AªºÀô¹Ò¬OVB.Net,¤W­z»yªk¬OVB6Àô¹Ò¤U°õ¦æªº
2. R.Length <  10 ©M size <  10 À³¸Ó³£¥i¥H
3.Console.WriteLine(Size + "¤p©ó" + Apath) À³¸Ó¤£·|¼g¤J¤å¦rÀÉ
4.©³¤U¬OMSDN¼g¤J¤å¦rÀɪº½d¨Ò,½Ð°Ñ¦Ò­×§ï¡G
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
BOB

TOP

¦^´_ 7# webbliu


    §ï¼gMSDNªº½d¨Òµ{¦¡½XÀ³¸Ó¤£Ãø¤~¹ï~

       Dim path as string

        If File.Exists(path) Then         '¦pªGÀɮצs¦b
           If File.Length <  10 Then   'ÀH«K§A­n¥[¤°»òµ{¦¡½X         
           Else
           End If
       Else        '¦pªGÀɮפ£¦s¦b
           Using atxt As StreamWriter = File.CreateText("C:\exists.txt")  '¶}ÀÉ
            atxt .WriteLine("¤U¦CÀɮפ£¦s¦b¡G" )  '¼g¤J¤@¦æ
            atxt .WriteLine(path) '¼g¤J¤£¦s¦bªºÀɮ׸ô®|
            atxt .Close() 'Ãö³¬ÀÉ®×
           End Using
        End If

§Æ±æ¹ï§A¦³À°§U~
BOB

TOP

¦^´_ 9# webbliu


1. FileInfoÃþ§OªºFile.LengthÄÝ©Ê¥»¨Ó´N¬O¦^¶Ç«ü©wªºÀɮפj¤p,³æ¦ì¬°bytes,¤£»Ý¥t¥~¼g¤@­ÓFunction
2.§ÚÁÙ¨S¬Ý¹LÀɮפj¤p¬°­t¼ÆªºÀÉ®×,©Ò¥HÀ³¸Ó¥Î¤£¨ìÀɮפj¤p<0 ³o¼Ëªº§PÂ_¦¡
3.¤£¦s¦bªºÀɮקAµLªk¦C¥X,¦ý¬O¥ÎÀɮפj¤p¤ñ¹ï«o¥i¥H¥þ³¡¦C¥X,ªí¥Ü¤£¬O§A¦C¥X¦³°ÝÃD,°ÝÃDÀ³¸Ó¥X¦b§Aªº§PÂ_¦¡ÅÞ¿è,«Øij§A¦h¹Á¸Õ¤£¦PªºÅÞ¿è¼gªk,©Î³\¯à¦Û¤v§ä¨ì§A­nªºµ²ªG
BOB

TOP

        ÀR«ä¦Û¦b : ¹D¼w¬O´£ª@¦Û§Úªº©ú¿O¡A¤£¸Ó¬O¨þ¥¸§O¤HªºÃ@¤l¡C
ªð¦^¦Cªí ¤W¤@¥DÃD