getfile method 
Author Message
 getfile method

In the code below for filespecs I entered c:\GIL\Myfile
but I keep getting an error at the colon. How do I make
this code work?

Private Sub Command26_DblClick(Cancel As Integer)
    Dim fs, f, s
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFile(filespecs)
    s = f.Name & " on Drive " & UCase(f.Drive) & vbCrLf
    s = s & "Created: " & f.DateCreated & vbCrLf
    s = s & "Last Accessed: " & f.DateLastAccessed & vbCrLf
    s = s & "Last Modified: " & f.DateLastModified
    MsgBox s, 0, "File Access Info"
End Sub



Thu, 15 Jul 2004 00:51:16 GMT  
 getfile method
I enter put quotes ("c:\\Gil\\Myfile") around the path and
now I am getting file not found error.  What am I doing
wrong?
Quote:
>-----Original Message-----
>In the code below for filespecs I entered c:\GIL\Myfile
>but I keep getting an error at the colon. How do I make
>this code work?

>Private Sub Command26_DblClick(Cancel As Integer)
>    Dim fs, f, s
>    Set fs = CreateObject("Scripting.FileSystemObject")
>    Set f = fs.GetFile(filespecs)
>    s = f.Name & " on Drive " & UCase(f.Drive) & vbCrLf
>    s = s & "Created: " & f.DateCreated & vbCrLf
>    s = s & "Last Accessed: " & f.DateLastAccessed &
vbCrLf
>    s = s & "Last Modified: " & f.DateLastModified
>    MsgBox s, 0, "File Access Info"
>End Sub
>.



Thu, 15 Jul 2004 01:20:24 GMT  
 getfile method
Hi,
Why do you have two backslashes and no file
extension?
It should be "c:\Gil\Myfile.something"

HTH
Dan Artuso, MVP

Quote:

> I enter put quotes ("c:\\Gil\\Myfile") around the path and
> now I am getting file not found error.  What am I doing
> wrong?
> >-----Original Message-----
> >In the code below for filespecs I entered c:\GIL\Myfile
> >but I keep getting an error at the colon. How do I make
> >this code work?

> >Private Sub Command26_DblClick(Cancel As Integer)
> >    Dim fs, f, s
> >    Set fs = CreateObject("Scripting.FileSystemObject")
> >    Set f = fs.GetFile(filespecs)
> >    s = f.Name & " on Drive " & UCase(f.Drive) & vbCrLf
> >    s = s & "Created: " & f.DateCreated & vbCrLf
> >    s = s & "Last Accessed: " & f.DateLastAccessed &
> vbCrLf
> >    s = s & "Last Modified: " & f.DateLastModified
> >    MsgBox s, 0, "File Access Info"
> >End Sub
> >.



Thu, 15 Jul 2004 06:54:41 GMT  
 getfile method
Four problems:
    1. You have double backslashes. Remove them!
    2. You haven't specified a file extension. Add one.
    3. fs should be declared as type *FileSystemObject*, not *variant*
    3. f should be declared as type *File*, not *variant*.

For example:
    Dim fs As New FileSystemObject, f As File, filespecs As String
    'You can instantiate a new FileSystemObject using CreateObject, but I
find it easier this way.
    filespecs = "c:\Gil\Myfile.bat"
    Set f = fs.GetFile("c:\test.txt")

- Graham R Seach MVP


Quote:
> I enter put quotes ("c:\\Gil\\Myfile") around the path and
> now I am getting file not found error.  What am I doing
> wrong?
> >-----Original Message-----
> >In the code below for filespecs I entered c:\GIL\Myfile
> >but I keep getting an error at the colon. How do I make
> >this code work?

> >Private Sub Command26_DblClick(Cancel As Integer)
> >    Dim fs, f, s
> >    Set fs = CreateObject("Scripting.FileSystemObject")
> >    Set f = fs.GetFile(filespecs)
> >    s = f.Name & " on Drive " & UCase(f.Drive) & vbCrLf
> >    s = s & "Created: " & f.DateCreated & vbCrLf
> >    s = s & "Last Accessed: " & f.DateLastAccessed &
> vbCrLf
> >    s = s & "Last Modified: " & f.DateLastModified
> >    MsgBox s, 0, "File Access Info"
> >End Sub
> >.



Sat, 17 Jul 2004 00:15:33 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. ASP GetFile method

2. GetFile Method

3. GetFile method

4. Multiple filetypes in Directory.GetFiles?

5. Unexpected results using GetDirs/GetFiles

6. Directory.GetFiles() Question

7. Directory.GetFiles???

8. GetFile into array of structured type and Option Strict On

9. GetFile with URL?

10. Internet Control Pack - FTP GetFile Problem

11. Changing sort order with GetFiles

12. Unable to use GetFile / GetFolder after SRP (security rollup package)

 

 
Powered by phpBB® Forum Software