0

This may be an ancient problem.

So, I have a C# application that allows the user to insert images, usually photos, so it can register any problems found on the working site.

When it was being used on a local network, the user could use the OpenFileDialog() with no problem as the user could use all shortcuts so access their folders.

Now we migrated the application to an AWS server, but the OpenFileDialog() now allows the user to access all folders in the virtual machine. Not only that, the user can create, edit or delete folders and files, which can be problematic.

As far as I could find, there is no way to restrict the OpenFileDialog window (thanks Microsoft, it has been a problem for over a decade, and it is still not solved), so it needs a workaround.

Problem: I need a fileDialog window that looks similar to the OpenFileDialog one, but it should have te following restrictions:

  • The user cannot access any directory located outside its own computer;
  • The user cannot create, edit or delete folders and files;

If possible, I would like to have the Quick Access menu, so the user can navigate faster.

All users PCs are Windows 7 or later.

The first attempt was obviously the OpenFileDialog.InitialDirectory one:

OpenFileDialog.InitialDirectory = @"\\tsclient\C\Users\"; = @"\\tsclient\C\Users\"; which is only a change on the initial directory. 

But the result was allowing the user to basically do whatever, that was the start of my search.

Validating the selected file does not help much against the create, edit or delete.

Fernando
  • 128
  • 1
  • 1
  • 9
  • I can't see how a client side operation within a application can change behaviour just because it was moved from one Windows machine to another Windows machine (AWS). Are you sure that's the only change that results in the change in behaviour? – Ermiya Eskandary Nov 11 '22 at 15:07
  • You could use the [`FileOk` event](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.filedialog.fileok?view=windowsdesktop-7.0) to check the path before letting the user proceed and if they're in the wrong place, you could stop them from progressing but I don't think this is possible outside the box and like I said, not really sure how the AWS part is affecting this (or if it's a red herring). – Ermiya Eskandary Nov 11 '22 at 15:10
  • @ErmiyaEskandary, yes I am sure of it, it worked perfectly before. The application is now installed at the AWS machine and the user executes it using an ConnectLauncher(TSClient) instance. This instance works as if the AWS machine executed the program, not the end-user. The FileOk event is no good as I want to stop the user from creating, editing or deleting folders and files. – Fernando Nov 11 '22 at 17:14

0 Answers0