Path: csiph.com!news.mixmin.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Greg Newsgroups: it.comp.lang.visual-basic Subject: Re: funzione Dir Date: Fri, 09 Oct 2015 16:19:34 +0200 Organization: solani.org Lines: 42 Message-ID: References: <4cbc1bla3674309egh2l25i74tbvfiiqm8@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15"; format=flowed Content-Transfer-Encoding: 8bit X-Trace: solani.org 1444400375 14693 eJwNx8kBwCAIBMCWlGUxlIMc/Zdg5jeEbcujRlMO57tSOgD75DStXZa0YrTCeQO+/8AiaqWHPCMPEV8= (9 Oct 2015 14:19:35 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Fri, 9 Oct 2015 14:19:35 +0000 (UTC) X-User-ID: eJwNysEBwCAIA8CVkBKUcQDJ/iPYex8+X97bHG4guIm5wjhmmplLAB6dKnjVZWhh/m3a0ZaQBye1EWI= X-Newsreader: MesNews/1.08.03.00-it Cancel-Lock: sha1:wvyKJmxBDDjQif0mWfMM5nWneq0= X-NNTP-Posting-Host: eJwFwYEBACAEBMCVkH8aJ8X+I3SHReUNJ+gYDD1FcrdE1POhXSvLKvQsPad1MwzBbvSr8A8Q7hEN Xref: csiph.com it.comp.lang.visual-basic:18539 Il 08/10/15 10:56:17 SB ha scritto: > Il giorno Wed, 07 Oct 2015 20:05:59 +0200, Greg ha scritto: >> Mi sono accorto oggi che la riga: >> x= Dir("G:\miofile.txt") >> mi restituisce Vuoto anzichč "" quando il drive non č presente. A cosa >> potrebbe essere dovuto? > Ti hanno gią risposto sul tipo di dato che restituisce Dir, io invece ti > consiglio di non usarlo e per verificare l'esistenza di un file uso l'api > GetFileAttributes, tra l'altro puoi sapere se č una direcory e altre info > Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" > (ByVal lpFileName As String) As Long > Const INVALID_HANDLE_VALUE = -1 > Const FILE_ATTRIBUTE_ARCHIVE = &H20 > Const FILE_ATTRIBUTE_DIRECTORY = &H10 > Const FILE_ATTRIBUTE_HIDDEN = &H2 > Const FILE_ATTRIBUTE_NORMAL = &H80 > Const FILE_ATTRIBUTE_READONLY = &H1 > Const FILE_ATTRIBUTE_SYSTEM = &H4 > Const FILE_ATTRIBUTE_TEMPORARY = &H100 > x& = GetFileAttributes ("G:\miofile.txt") > If x& > 0 Then MsgBox ("ESISTE") Ciao SB, sto provando l'api che mi hai suggerito su due diversi pc, xp e seven tutti a 32 bit. Per testare l'esitenza di un file va benissimo, sempre, ma se voglio testare anche gli attibuti del file (ed evitare cosi anche GetAttr) mi da risultati diversi: Dim k as Long k = GetFileAttributes ("G:\miofile.txt") su XP mi restituisce 8224 e su Seven 32. Come mai? -- Greg