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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top