question

KailashSahu-8768 avatar image
0 Votes"
KailashSahu-8768 asked RLWA32-6355 commented

How Do I Prevent Files In Usb From Being Copied Or Deleted Using C#.

I want to develop an windows application which restrict users to copy media files from USB (be it mp3,mp4, etc.) based on password protection. user can only play media files and can't copy or delete. please suggest me some solution with example if possible...

dotnet-csharp
· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@KailashSahu-8768, Based on my research, I think the possible way is that we need to start with the permission side. You could refer to the link Set File Permissions in C# to use c# code to set permission for the files in usb.
After setting it, we could check it as the following:
146471-image.png


0 Votes 0 ·
image.png (98.9 KiB)

A drive connected through USB could be a flash drive with a file system other than NTFS. Furthermore, the Windows access control model is based on user identity, not on applications. So it cannot reasonably be used to differentiate between opening a media file to play it with a particular program or opening it with a different program to copy it. Both actions require read access.

Adding the Everyone group to the security descriptor of a file with a Deny Ace for all privileges is not a very good idea. Windows issued the following warning for such an action -

146545-warning.png

The following illustrates how even the SYSTEM account was denied access if the file system permissions were changed as suggested -

146528-denysystem.png


0 Votes 0 ·
warning.png (121.2 KiB)
denysystem.png (13.0 KiB)

I want to copy my data from PC to pendrive, once data is copy on my pendrive,
Everyone can't delete my data on every PC

0 Votes 0 ·
Show more comments

I want to copy my data from PC to pendrive, once data is copy on my pendrive,
Everyone can't delete my data on every PC.

0 Votes 0 ·

@KailashSahu-8768, I suggest that you can set a shared folder for everyone and put the data in the shared folder. Then you can set only the read permission for everybody and set all permissions for you.

0 Votes 0 ·

1 Answer

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered KailashSahu-8768 published

As suggested, you can not prevent copying usb files unless you create your own usb file format. You do this by using a raw read/write usb library. In this case you will also need to supply you own player because standard players can not read the files.

The other more common approach is to encrypt the files with DRM. If you can stream rather than use usb look at

https://docs.microsoft.com/en-us/azure/media-services/latest/drm-content-protection-concept

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I want to copy my data from PC to pendrive, once data is copy on my pendrive,
Everyone can't delete my data on every PC..

0 Votes 0 ·