Stream and run Managed.Dll? - c#

Let's say I have a want to make a licesing system where my user authecticates against my ASP.Net website from my desktop application.
Would it than be possible to stream a Managed .Dll (C# .Dll) File or .Exe I guess and make it run on my Clients Computer without saving the file to disk?
So when my User stops using it he should not have access to the file.
If so what should I look into to make this happen?

Browser security don't allow you to do this.
But you can use a litle exe which download lib, and using reflection load it and run.

Related

Multiple executable accessing the same folder at the same time

We have a python application that checks a directory(C:\sample\folder) every 5 seconds, there's also this external application(.net app) that puts file into that same directory (C:\sample\folder).
Will there be any conflict when the two application access the same folder at the same time (accidentally)?
Conflicts like :
the external app wont be able to place a file because the python app is currently walking through that same directory?
It should be fine for the external app to create and write to a file. If the Python app is reading a file, the .NET app may not be able to write to it while Python is reading it, without both processes opening the file in a shareable way, however.
Likewise if the Python app is going to start reading the newly-created file, it may either find that it can't do so until the .NET app has finished writing to it, or it may read incomplete data. Again, changes would quite possibly be required to both processes to allow reading at all.
It's worth thoroughly testing all the poosibilities you're concerned about, possibly involving the creation of a "fake" external app which writes to a file very slowly, but opening it in the same way that the real one does.

How to use image without making .exe heavier c#

How to use image without making .exe file heavier in c# windows application.
One way is keeping the file in debug folder and reading it at runtime but i dont want the user to see any images in the debug folder.
How can i achieve this?
You could store images in a separate Class Library and then reference it in your application.
Users wouldn't be able to see the image files this way, instead they would be stored as a dll file in your debug folder.
Edit:
I have recorded the actions required to achieve this setup, check out this link:
https://www.youtube.com/watch?v=8i794GmZ_aI

Methods of spawning a file on the native user's computer from a wpf application?

I created a wpf application that can create, write to, and read from a .txt document to store and persist data. Currently the application creates the text file within the solution folder, but what I would like to accomplish is the ability of the executable file to act as a stand-alone application that can spawn the text file somewhere on the user's computer, and continually persist and retrieve data from that file.
So, theoretically I could send a copy of the executable to a friend, they could open it and upon saving data a file would be spawned on their computer which would then be called whenever the application was run.
Right now what I had in mind for an answer is which folder I would need to use in this call within my application:
FileStream fs = new FileStream("ListOfTasks.txt", FileMode.OpenOrCreate);
StreamReader s = new StreamReader(fs);
Or otherwise, what other methods I could use to cause my executable to act as a stand-alone that can persist data without a database.
You don't want to be writing to the solution folder, since that will require administrative privileges on any Vista+ machine.
You might want to look into using the ProgramData folder, see this question for more information:
Write in "ProgramData" folder (W7 and Vista) .NET
This is an excellent resource for working out where you should be writing files, based on a few different scenarios:
Where should I put program data: http://blogs.msdn.com/b/cjacks/archive/2008/02/05/where-should-i-write-program-data-instead-of-program-files.aspx

.net WPF application create a secure folder

I am working on one desktop application which is built by using .net WPF. I have some data inside the application like images,videos..
I want to make this folder secure, so nobody can access the data inside the folder after application installation. Only the application can read the data from that directory.
Even though administrator of that machine can not open that folder to check the content.
Is it possible to have this kind of security inside the WPF application.
Only motive it to keep the sensitive data protected from external copy from the application users.
Thanks,
Vijay
It depends on how you use the resources.
Actually you could encrypt all "protected" files, so that after the installation every one can copy but no one can use them unless your application decrypts the files.
When you encrypt files you should definitively test the performance (decryption takes some time).
Two links showing how you could do it:
What's the easiest way to encrypt a file in c#?
http://lukhezo.com/2011/11/06/encrypting-files-in-net-using-the-advanced-encryption-standard-aes/
Add the file you would like to strongly protect to you solution. Then right click each file, go to properties and set its "build action" to "embedded resource".
And for how to access the resource stream from within the exe for use with in your application, see link below
How to compile all files to one exe?
That way, your private files will not be copied to the installation folder but will instead reside inside your .exe file.
WPF is beside the point. Applications run with the permissions of the users that start them. If an application needs access to files, then the user will also need rights to those files.
In short, the answer is no, you cannot do exactly what you are asking.
The best you will be able to do is make it hard for a user to discover where the assets are coming from, but you will never be able to give access to your application without giving access to the application's user.

Download open file

I want to download Word file with FTP (thanks to webClient object). It's working fine but not in this case :
Users of my company can open this Word files. So, when a user has opened a file the DownloadData command returns an exception :
error 550 : File unavailable (e.g., file not found, no access).
There is a way to download an opened file with FTP ? If not, what can i do ?
Thanks !
This is almost assuredly a poor architecture for whatever project you are working on. You probably want to separate the user editable document store from the downloadable document store. There are many solutions for keeping the two directories in sync when a change is made by a user (dropbox, mesh, or even custom scripts using robocopy and such).
When an Office program opens a file for modification, it intentionally opens it exclusively. As a result, no FTP server is going to be able to open it, unless it uses the backup API. If it uses the backup API, it may well get some intermediate state, since Office may be in the middle of writing something at any time. So no sane person implements an FTP server to use the backup API.

Categories