How to delete read-only files

  • Thread starter Thread starter Kit McDowall
  • Start date Start date
K

Kit McDowall

How can I delete read-only files with the .net compact
framework? The following works for the regular .net
framework but not for the compact framework:

SetAttr(strFilePath, GetAttr(strFilePath) And (Not
vbReadOnly))

File.Delete(strFilePath)

The .NET compact framework does not support the SetAttr
and GetAttr functions.
 
You can get and set file attributes through the System.IO.FileInfo class.
e.g.

Dim fi As New System.IO.FileInfo("filename")

'remove readonly attribute

fi.Attributes -= IO.FileAttributes.ReadOnly

System.IO.File.Delete("filename")


Peter
 
Back
Top