David,
"DavidB" <davidb@notreally_hotmail.com> schrieb:
I'm trying to delete a file with
File.Delete("c:\Documents and Settings\%username%\Application
Data\Microsoft\Excel\excel*.xlb")
On doing this I get an Exception "Illegal characters in path" - I assume
its
the %username% bit
I trierd
Dim UserName As String %username%
File.Delete("c:\Documents and Settings\" & UserName & "\Application
Data\Microsoft\Excel\excel*.xlb")
AFAIK 'File.Delete' does not support wildcards ("*", in this particular
case). The code below is untested, but it should give you an idea on how to
solve the problem:
\\\
Imports System
Imports System.IO
..
..
..
Dim FileNames() As String = _
Directory.GetFiles( _
Path.Combine( _
Environment.GetFolderPath( _
Environment.SpecialFolder.LocalApplicationData _
), _
"Microsoft\Excel\excel*.xlb" _
) _
)
For Each FileName As String In FileNames
File.Delete(FileName)
Next FileName
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>