I have an application in c#.net in which I have embeded the SWF file in SWFObject from COM Object.
Now after installation, the original SWF file also available in the application root directory. So from that place(application root directory) anyone can access that file. But I want to restrict that file from being opened.
axShockwaveFlash1.Movie = Directory.GetCurrentDirectory() + "\\XYZ.swf";
I did something like this.
So how can I restrict that file in application root directory such that only from my application I can access it..??
You can embed the file into a dll or exe file and play it from there. this way it is not (as a seperate file) in the file system at all.
For details see How to embed and access resources by using Visual C#.
You could save the swf file binary data as static bytes in your code and statically load them and convert back to an swf file. The conversion might take a little while but it only occurs once as you open the program.
Edit:
But k3b's answer is better.
Permissions are based on users, not applications, so the short answer is you can't. However, you can build your own application-specific authentication pretty easily. Have your SWF require specific FlashVars to be set in order to move beyond frame 1. People can still decompile your SWF but this will at least stop most people. Another option is to try to store the data within you binary somehow and load the SWF using a byte-array, see this post for one attempt at that.
Related
I would like to take a serialized file and save it to my recourses folder in project.
My reason for doing this (maybe there's a better way) is I have a published exe (single executable file) for the program that runs and when it creates a serialized file I don't want it to save it to desktop. I need to somehow save it to my exe without going outside of it.
Any advice on how I could do this?
It's very ugly.....but you could use an "alternative data stream" on NTFS system.
http://ntfs.com/ntfs-multiple.htm
https://learn.microsoft.com/en-us/sysinternals/downloads/streams
How to read and modify NTFS Alternate Data Streams using .NET
https://blogs.msmvps.com/bsonnino/2016/11/24/alternate-data-streams-in-c/
https://oddvar.moe/2018/04/11/putting-data-in-alternate-data-streams-and-how-to-execute-it-part-2/
https://blog.foldersecurityviewer.com/ntfs-alternate-data-streams-the-good-and-the-bad/
https://www.irongeek.com/i.php?page=security/altds
You'll probably have security scanners stopping you from doing it.
In addition if you copy the from an NTFS volume to say FAT, then alternative data streams are lost.
Also some backup software may not backup ADS properly.
https://wiki.sep.de/wiki/index.php/Support_for_NTFS_alternate_data_streams_(ADS)_for_Windows
https://www.2brightsparks.com/resources/articles/ntfs-alternate-data-stream-ads.html
https://community.osr.com/discussion/89308/alternate-data-streams-and-backups
https://social.technet.microsoft.com/Forums/Azure/en-US/007d5442-1cd8-4293-b717-b8fa72606189/ntfs-data-streams-broken-by-design-on-file-copy?forum=winserverfiles
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;
}```
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
I have a bit of a difficult use-case.
I have for example 20 pdf files on a CD along with a program, which is used to open these files. But I want the user, who is using the program, to be unable to open the pdf files from the filesystem. Only the program should be able to open these files (after the user has given the password to open the "archive")
I have no idea on how to start with this, hopefully somebody can give me a hint or a pointer.
Thank you guys in advance.
Encrypt the files and have the program perform the decryption. Note that this won't necessarily make it impossible for the user to open the files without your program, but will make it inconvenient.
I don't think there is a way to solve it as you have described it.
You can use the files system flag 'hidden', but many users have set their file explorer to see hidden files.
But of course you could scramble the file content (with a simple or complex encryption) or put it in a password protected zip.
You can use an external tool that encrypts the file into an exe file.
e.g.
http://www.drmsoft.com/pdf-to-exe-encrypter.asp
You can run the exe and give password from your program.
I have a program in C++ that stores certain files such as movies, mp3 & Flash in the AppData folder. The issue is that whilst generally hidden, the user can easily visit this folder and take any of these files.
Is there a way that the program can encrypt this folder so that it's not possible for the user to access the files (except through the software itself)?
Any other solutions (even if not related to the above) are much appreciated.
You can use your own program to encrypt a file or a folder.However you can use open source software like truecrypt.The software along with the code is available.Code is written in C,C++ and assembly
Why not simply encrypt the files and then decrypt them when they are loaded by the app. That way it does not matter if the user can access the files.
I'm using Silverlight 3 to write a LOB applcation that takes an input file, does some stuff, and then returns an output file. What is the easiest way to get the input file from the user and then return a file back to the user? Can I access the local file system to do this? How? Most likely the files will be ASCII files, but could be Excel some day (Hopefully soon).
You can access the local file system provided you go via the OpenFileDialog (for reading files) and the SaveFileDialog (for writing files). You can't access arbitrary files, only the ones where the user has seen and OKed the file dialog.
There is one exception to what itowlson says, you do have access to IsolatedStorage. However, this is limited. Access to "normal" files can only be through interaction of the user. This makes silverlight a much safer playground, from a user perspective, then older (like activex) technologies.