What code do I use to check if a file exists, and to check that the file is not a blank file (e.g. 0kb in size)?
Cheers :)
Printable View
What code do I use to check if a file exists, and to check that the file is not a blank file (e.g. 0kb in size)?
Cheers :)
Use System.IO.File.Exists() and System.IO.FileInfo.
Perfect :)
you could do something like this
That will check if c:\doc1.doc exists, if it does, it will delete it.VB Code:
If System.IO.File.Exists("c:\doc1.doc") Then System.IO.File.Delete("c:\doc1.doc")) End If
This might also be useful to you:
this checkes if a directory exists, if it does not, it creates it! ;)VB Code:
If Not (System.IO.Directory.Exists("c:\somefolder")) Then System.IO.Directory.CreateDirectory("c:\somefolder").Attributes = FileAttributes.Hidden End If
Oops, I think I was a little too late! :D