File Delete

  • Thread starter Thread starter Bjoern
  • Start date Start date
B

Bjoern

Hi,
how can i delete in Windows CE a File in the Directory
Windows\Fonts\ ?
File.Delete doesn't run ->unauthorized access exception
and File.Move makes only a copy.
The file is not write-protected.
Second question:
How can i delete a write-protected file?
Thx
 
Hi Bjoern,

On Windows XP the Windows folder requires special permissions for
manipulation, I expect this is true for CE also.

In order to delete a write protected file, set the file attributes to
FileAttributes.Normal.
You can use File.SetAttributes() or FileInfo.Attributes

Hope this helps

Chris
 
Christopher Kimbell said:
Hi Bjoern,

On Windows XP the Windows folder requires special permissions for
manipulation, I expect this is true for CE also.

In order to delete a write protected file, set the file attributes to
FileAttributes.Normal.
You can use File.SetAttributes() or FileInfo.Attributes

Hope this helps

Chris
 
To delete a write-protected file was successfull.
To delete the fonts-file was not possible.
Everytime the exception -> unauthorizedAccessException
with every attribute comes on my display.

This funktions were successfull to delete a write-protected file:
FileInfo fi = new FileInfo("\\FlashDisk\\file.doc");
fi.Attributes = FileAttributes.Normal;
File.Delete(\\FlashDisk\\file.doc");

for the Fonts this funktions don't run
FileInfo fi = new FileInfo("\\Windows\\Fonts\\bla.ttf");
fi.Attributes = FileAttributes.Normal;
File.Delete("\\Windows\\Fonts\\bla.ttf");

What can i do??How can i delete this file?
 
Hi,

Glad to hear that you managed to delete your read only file.

I am not familiar with the Compact framework, so this is just speculation.

A method I have found usefull in tracking down access errors, is to try and
modify it using explorer.
If you can delete the file yourself using explorer, you should be able to
delete the file from code.

If you can't delete it using explorer, it looks like you don't have enough
priviliges. If you managed to create the file, but not delete it, the file
is probably in use by something.

Chris
 
Back
Top