0

I am learning C#, and have created an application with winforms that can play video files from my local hard drive. Here is my code for playing a file that is stored in the same directory as my exe file.

My question is - the actual file is still accessible to anyone that can access my exe folder, and therefore, can play the video file just by clicking on it. Is it possible to embed the video file in such a way that the actual video file remain inaccessible to someone I give my application to use? I mean he/she should only be able to use the exe file to access the application and then play the video using the application.

I have read this post here to get some idea: How to store a video file in exe file in c# and play it

However, this answer is also getting the physical file url, converting to bytes from resource and then using the url to play. Therefore, if I had to give my application to someone else I would still have to copy the physical file to a folder, and again it remains accessible for an open-by-click option.

I am a complete newbie on this, so advance thanks for helping me out.

       {
           string exepath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);

           string vdopath = System.IO.Path.Combine(exepath, "MyFolder\\SecondFolder\\VideoFile.mkv");

           axWindowsMediaPlayer1.stretchToFit = true;
           axWindowsMediaPlayer1.URL = vdopath;
       }```
Inferno1892
  • 233
  • 1
  • 3
  • 11
  • We're going to need a lot more context on these video files. Why do you want to prevent people from playing them? Are they shipped alongside your app? Is this basically a question about copy protection/DRM? – Ian Kemp Oct 05 '20 at 11:22
  • Well if someone is able to browse through the folders and can play the files using a regular media player, I guess my application would be kind of useless? I am just looking for a way to make the users play the video files from my application, using my application only. At this point I have all the video files in a folder in the same folder as my exe file. – Inferno1892 Oct 05 '20 at 11:24

1 Answers1

0

It's possible to add any file to a project and from the Properties set the Build Action to "Embedded Resource", then to read the file this SO answer - https://stackoverflow.com/a/3314213/4000335

kshkarin
  • 574
  • 4
  • 9