check string as valid filename 
Author Message
 check string as valid filename

Hi!

How can i check whether a string is a valid filename? Is
there an api function call perhaps to check a string like
"file/notvalid.txt"? (the slash is not valid!)

Regards,
Heiko



Sun, 02 Nov 2003 15:01:47 GMT  
 check string as valid filename
Hello!

No need for winapi...

If Dir("c:\boot.ini", vbNormal + vbHidden +vbSystem +vbReadOnly) <> "" Then
   'exists
End if

Regards,
------------------------------------------------------
Niklas Lagergren, MCP, MCSD

http://www.isab.se
IndustriSystem i Karlskoga AB
---------------------------------------------------------
"Datorer g?r som man s?ger ?t dem,
inte som man vill"
---------------------------------------------------------


Quote:
> Hi!

> How can i check whether a string is a valid filename? Is
> there an api function call perhaps to check a string like
> "file/notvalid.txt"? (the slash is not valid!)

> Regards,
> Heiko



Sun, 02 Nov 2003 15:23:22 GMT  
 check string as valid filename
Hi,

FileSystemObject form Microsoft Scripting Runtime has FileExists metod.
--
HTH,
Alexander Shirshov, MCSD


Quote:
> Hi!

> How can i check whether a string is a valid filename? Is
> there an api function call perhaps to check a string like
> "file/notvalid.txt"? (the slash is not valid!)

> Regards,
> Heiko



Sun, 02 Nov 2003 15:58:50 GMT  
 check string as valid filename

Quote:
> Hi,

> FileSystemObject form Microsoft Scripting Runtime has FileExists metod.
> --
> HTH,
> Alexander Shirshov, MCSD



> > Hi!

> > How can i check whether a string is a valid filename? Is
> > there an api function call perhaps to check a string like
> > "file/notvalid.txt"? (the slash is not valid!)

> > Regards,
> > Heiko

Sorry, i didn't express it correct :

There's no need that the file is an existing one, my question was
whether the string contains a valid filename not an existing filename.

I've found that one:
http://support.microsoft.com/support/kb/articles/Q177/5/06.ASP

Thanks,
Heiko



Sun, 02 Nov 2003 17:02:22 GMT  
 check string as valid filename
    If InStr(1, strFile, "*") Or _
       InStr(1, strFile, "/") Or _
       InStr(1, strFile, "?") Or _
       InStr(1, strFile, ":") Or _
       InStr(1, strFile, "|") Or _
       InStr(1, strFile, "<") Or _
       InStr(1, strFile, ">") Then

       'filename is not valid
    Else
       'filename should be valid
    End If

that's the way i'd do it (and it's perhaps also the worst way of doing it).



Quote:
> > Hi,

> > FileSystemObject form Microsoft Scripting Runtime has FileExists metod.
> > --
> > HTH,
> > Alexander Shirshov, MCSD



> > > Hi!

> > > How can i check whether a string is a valid filename? Is
> > > there an api function call perhaps to check a string like
> > > "file/notvalid.txt"? (the slash is not valid!)

> > > Regards,
> > > Heiko

> Sorry, i didn't express it correct :

> There's no need that the file is an existing one, my question was
> whether the string contains a valid filename not an existing filename.

> I've found that one:
> http://support.microsoft.com/support/kb/articles/Q177/5/06.ASP

> Thanks,
> Heiko



Sun, 02 Nov 2003 18:34:50 GMT  
 check string as valid filename
As long as you can count on IE4+ installed, there are alot of "built in"
functions you can use...

Shell Path Routines: IsPathAFile
http://www.mvps.org/vbnet/index.html?code/fileapi/pathisfilespec.htm


Quote:
> > Hi,

> > FileSystemObject form Microsoft Scripting Runtime has FileExists metod.
> > --
> > HTH,
> > Alexander Shirshov, MCSD



> > > Hi!

> > > How can i check whether a string is a valid filename? Is
> > > there an api function call perhaps to check a string like
> > > "file/notvalid.txt"? (the slash is not valid!)

> > > Regards,
> > > Heiko

> Sorry, i didn't express it correct :

> There's no need that the file is an existing one, my question was
> whether the string contains a valid filename not an existing filename.

> I've found that one:
> http://support.microsoft.com/support/kb/articles/Q177/5/06.ASP

> Thanks,
> Heiko



Tue, 04 Nov 2003 05:40:57 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Checking for valid filename

2. Checking if string contains valid GUID

3. DOS wildcard, *, not valid with .FileName?

4. valid filenames for shell functions?

5. Valid Filenames?

6. Detecting if a filename is a valid picture file

7. Converting an invalid filename to a valid one

8. API to test for valid filename?

9. Valid FileName

10. Method for checking for valid dates in a query

11. Check if a date field is valid

12. Check for valid file or directory

 

 
Powered by phpBB® Forum Software