Deleteing ReadOnly Files from Directory
Normally the delete folder/sub folder API wont delete any read only files in the directory. The following code snippet will allow you to forcefully delete all the files in a folder.
.Net API => Directory.Delete(Folder name)..cant delete read only files.
For deleting Read only files:
1: string command = @"c:\Windows\System32\CMD.exe";
2: string parameter = @"/F c:\temp\MyReadOnlyFile.txt";
3: ProcessStartInfo startInfo = new ProcessStartInfo(command, parameter); startInfo.CreateNoWindow = true;
4: Process.Start(startInfo); For Directories use RMDIR command with /S & /Q arguments.
Haahaaa I think I have already introduced a simple mechanism to delete readonly files in the WFCommon FolderHelper. Interesting...
ReplyDeleteohh i c....let me check...
ReplyDelete