• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 390
  • Last Modified:

I need some help with a Directory.delete problem.

I have created a C# Console application that automatically goes into a folder and cleans up some subfolders. When running the script it works fine for the most part. but on certain folders. i get the following error:

Access to path '<drive>:\users\<users folder>\<subfolder>' is denied.

I have checked my permisions on the files/folders and on all of them i have full permissions for all files, folders, and subfolders. so why am i getting this message? any help would be appreciated.


System.IO.Directory.Delete(path_to_delete, true);

Open in new window

0
tosmserversupport
Asked:
tosmserversupport
  • 3
  • 2
1 Solution
 
RishadanPortCommented:
This could happen if a file is currently in use by another program, or the current application.
0
 
tosmserversupportAuthor Commented:
I will look into this and see if that is the problem. thank you for your prompt response.
0
 
trunghieubkitCommented:
You may be opening the folder by the Explorer

0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
tosmserversupportAuthor Commented:
thank you for your help. it appears that there is a process running on the server which is preventing it from being deleted.
0
 
tosmserversupportAuthor Commented:
Thanks everyone for their prompt reply. it seems a program is accessing the files while i am attempting to delete them. I will write some code to remove these locks before deleteing the folders.
0
 
RishadanPortCommented:
Did I answer your question fully? I am just wondering why you gave the grade of "B". Usually you give the grade B when your answer was not answered fully
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now