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

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

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

¥»©«³Ì«á¥Ñ webbliu ©ó 2011-8-4 07:11 ½s¿è

Dear ¤j¤j­Ì¡A


½Ð°Ý

¥ÎDir §PÂ_Àɮצs¦b§_®É¡A  ¤]¦³¨Ï¥ÎFile.Exists ªº¤è¦¡

¯à§_§â§PÂ_µ²ªG¤£¦s¦b Falseªº¸ô®|ÀÉ®× ¿é¥X¦Ü¤å¦rÀÉ®×?

³q±`§PÂ_Àɮק¹³£¬O¥H MessageBox.show ("¨q¥XÀɮפ£¦s¦b")

¸Ó¦p¦ó¼g ¤~¯à§â©Ò¦³¤£¦s¦bªºÀɮ׳£¿é¥X¦Ü ¤å¦rÀÉ®×.txt??

¦³«Å§iDim path as String¡A·|¦P®ÉÀˬd«Ü¦hÀɮסC

§Ú·Q­n¥u¦C¥X§PÂ_ÀÉ®×µ²ªG¬°False "¤£¦s¦b" ªº ("¸ô®|ÀÉ®×")~~
½Ð«üÂI~ ÁÂÁ¤j¤j­Ì

if Dir ("path/files") =False  Then

writeline (false path: .....)

¤]³\¦h¥b¤H³£¹³§Ú¤@¼Ë¡A¤@ÀYÃú¤ô§a¡C
¸Ô²Ó¨Ç¥i¸û§Ö±o¨ì¦^ÂСC

TOP

¦^´_ 2# chin15


    Dear  
¦pªGÁÙ¬O¬Ý¤£À´ ½Ð¦^´_¡C
«D±`·PÁÂ~

TOP

¥»©«³Ì«á¥Ñ 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

¥»©«³Ì«á¥Ñ webbliu ©ó 2011-8-5 11:57 ½s¿è

¦^´_ 4# elinbit


    Dear ¤j¤j ÁÂÁÂ~
  ½Ð°Ý~~
   ±ý°õ¦æ®É¥X²{ open ¥¼«Å§i"  ½Ð°Ý¸Ó­È ­n«Å§i¬Æ»ò?
   open FileNum ¤]¬O

Dear ¤j¤j ¶¶«K ½Ð±Ð

¦pªG¬O³o¼Ë

¥ØªºÁÙ¬O¦b§ä¥X¤£¦s¦bªº"¸ô®|ÀÉ®×"
Apath ¬O±qTable Ū¥Xªº"¸ô®|ÀÉ®×"¡A«Ü¦hµ§¡C
¤U­±¨â¬qµ{¦¡ §Ú¦b°µ¤ñ¸û«á ¡A  ¤p©ó10byteªºÀÉ®× ³£µLªk¿é¥X¦Ü.txt¡C
½Ð°Ý¸Ó¦p¦ó­×¥¿
«D±`·PÁÂ
  1. Dim Apath as string  
  2.         Dim R As System.IO.FileInfo
  3.              
  4.             For i = 1 To n  
  5.             R = My.Computer.FileSystem.GetFileInfo("Apath")  
  6.             If R.Length <  10 Then  '½Ð°Ý³o¸ÌªºR.length §ï«ç»ò¼g©O
  7.             Console.writeline(size + "¤p©ó" + Apath)  
  8.             End If  
½Æ»s¥N½X
  1. Dim size as long
  2.         Dim Apath as string
  3.          
  4.         For i = 1 To n
  5.         On Error Resume Next
  6.         size = Filelen(Apath)
  7.         If size <  10 Then
  8.         Console.writeline(size + "¤p©ó" + Apath)
  9.         End If
½Æ»s¥N½X

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

¦^´_ 6# elinbit


    Dear ¤j¤j
MSDN ³o¬q§Ú¬Ý¤£À´
¯à§_½Ð§A«ü¾É¡A§Ú¸Ó¦p¦ó§â    exists §PÂ_¤£¦s¦bªºÀÉ®×+¸ô®|¿é¥X¨ì¤å¦r?
  1. Dim path as string
  2. Dim atxt as  new system.Io.StreamWriter("C:\exists.txt")

  3. If system.io.file.exits("path") Then
  4. '§PÂ_¤£¦s¦b ¿é¥X¨ì¤å¦rÀÉ®×.txt
½Æ»s¥N½X

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

¦^´_ 8# elinbit


    Dear ¤j¤j

§Ú·Q½Ð°Ý  ­n¨ú±oÀÉ®×®e¶q¸ê°T¡A¬O¤£¬O­n¥Î Fuction GetFilesize

ÁÙ¬O¥i¥Hª½±µ getfilesize
³o¬O§Ú¼gªº¤@¬q¡A¤£ª¾¹D³o¼Ë°µ¹ï¤£¹ï?
  1. Private Function GetFileSize(ByVal p1 As String) As Integer
  2.         Dim myfile As New FileInfo("C:\H.mov")
  3.         Dim filesize As Long = myfile.Length
  4.         Return filesize
  5.     End Function
½Æ»s¥N½X
­ì¥»¬O¥´ºâ§PÂ_FileExists   ¦pªGÀɮפ£¦s¦b¡A´N¦C¥X¥Ø¿ý(¥]§t¸ô®|)......
¦ý«ç»ò¼Ë³£°µ¤£¨ì...§Ú¤Ó»¹¤F¡C

«á¨Ó¬O¥´ºâ¥Î¤ñ¸ûÀÉ®×®e¶q¤j¤p¡A¤p©ó0ªºÀɮצC¥X¥Ø¿ý¤]¥]§tÀɮ׸ô®|......
¦ý¤£ª¾¹D¬°¦ó¡AµL½×¤j©ó¤p©ó0³£¦³³Q¦C¥X......¡C

²{¦b¹J¨ì²~ÀV¤F¡AÁٽФj¤j«ü±Ð¡C
ÁÂÁ¤j¤j!

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 : §g¤l¦p¤ô¡AÀH¤è´N¶ê¡AµL³B¤£¦Û¦b¡C
ªð¦^¦Cªí ¤W¤@¥DÃD