0

I am creating an application that put file in user profile. Now, i want to upgrade that file, the problem is, how to find the file that is in the other user profile. I know we can expand environmental variables, but it will only expand the current user only.

Example: The file I create is in %USERPROFILE%\MyApplicationName\Directory\FileIWantToAccess

but then, this application is can be run by many user. Using expand user profile is not helping. so, if we have 2 user or more: UserA\MyApplicationName\Directory\FileIWantToAccess UserB\MyApplicationName\Directory\FileIWantToAccess

if i run it as user Admin, i want to delete all of them, how to find/delete/move them ?

Kosmas
  • 353
  • 4
  • 11

2 Answers2

0

From here you can get the windows users list, and then add it to your address to delete it

foreach(string userName in userList)
    File.Delete(userName+@"\MyApplicationName\Directory\FileIWantToAccess\YouFileName");
Community
  • 1
  • 1
Ghasem
  • 14,455
  • 21
  • 138
  • 171
0

You should consider doing this update at the next startup of the application.

Consider a redirected user profile, even if you are a local admin, you still wouldn't have rights to the share.

Or the user has the files locally, but encrypted. In that case you will hit a Security Exception when you try to replace/update the file.

Anemoia
  • 7,928
  • 7
  • 46
  • 71
  • I can't do that, because i want my application only read from one folder. And that new folder is not in the user profile anymore. – Kosmas Oct 01 '14 at 13:09