how to create password to folder Or secure folder using c# - c#

I am working on a windows form application using c#. There are some important files near my project that I do not want anyone to have access them but my application needs files.
The first solution was using DotNetZip library with password.
But when the application want to use these files the zip file must unzipped and all files copy in hard disk.
Is there a solution without direct access to the files to use them?
Or is there a solution that can be secured folders?

You could consider encrypting the passwords and not worry about people accessing it. If this does not work then you could also consider using a database to store your passwords.

Related

.NET download one Zip file when files are on different server

my users upload their files in my Web Application and the application saves their files in the server that has the most free space. The result is that one folder of a user may contain multiple files that are saved in multiple servers.
Now i want to give my users the option to download their whole folder as a ZIP file.
Can somebody provide an appropriate namespace or guidance of what will be the best practice to achieve this functionality?
The application is written in C# .NET. So far i saw
1) http://msdn.microsoft.com/en-us/library/system.io.packaging.aspx
together with
2) http://msdn.microsoft.com/en-us/library/system.io.packaging.zippackage.aspx
Am i looking at the right direction?
Let say a user has his files over 3 servers named server1,server3 and server6
point 1. You must have those locations somewhere? right?
now suppose server7 needs to pack those files into 1 zip and stream to the client.
You will need to download all those files to server7 and then pack those files to zip archive.
To download the files you can use webrequest method. Hope this is clear.
YOU WILL NEED TO DOWNLOAD THE FILES TO A SINGLE LOCATION BEFORE ZIPPING THEM, there is no shortcut over this.

Can i use File.Encrypt for this purpose?

I have an application, its Name and Logo can changed directly from a TXT and a PNG file in the same directory.
I want to give the user the ability to change the Logo and Text File from another application that does the following :
Takes the Logo.png , Name.txt file paths and the directory of my Software then encrypt these two files and put them in the Directory of the Software
In the other hand. The software will Decrypt these two files and write them to Hard Disk to temp directory then use them to display the name and the logo.
I searched for the simplest and easiest way to encrypt a file and i found :
From the MSDN :
File.Encrypt():
Encrypts a file so that only the account used to encrypt the file can decrypt it.
Could someone please tell me what does it mean "only the account used to encrypt a file can decrypt it"
What about encrypting the application from Computer1 by Application1 then the file will be decrypted by Computer2 in Application2
Will the encryption work correctly ?
Edit:The purpose why I need to encrypt these two files is to avoid users from directly change the Logo and the Name of Application from the directory
This will encrypt the file, but not as you expect - and almost certainly not such that it can be decrypted by another application/user on a different computer.
The Encrypt method basically just toggles a feature of the underlying NTFS driver to encrypt the specified file on the file system itself. The nice feature is that it (typically) provides seamless file encryption for the user, but it isn't really portable encryption. It is the same as opening the file properties, clicking the advanced button and selecting the "Encrypt" checkbox.
More information on the encrypting feature of NTFS can be be found here: http://technet.microsoft.com/en-us/library/bb457116.aspx
No. You should use a proper encryption method such as those in System.Security.Cryptography namespace. There is a stream implementation for this, too, called CryptoStream, which you may wrap a FileStream with for encrypting files with.
This is related to Windows' EFS.
You can try it from Windows Explorer by right-clicking on the file, Properties, Advanced, Encrypt contents. The file data is automatically decrypted/encrypted on the fly as your app accesses it. But if another user logs in the machine and copies the file it will appear encrypted since the encryption is based on a user token.
This is may or may not be what you want and that depends on your intended use of that feature. If you don't want the user to be able to modify the data outside your app it won't be enough.

how to create an ASP.NET Web Page to manage folders and files for loading and reading to an external server?

I need to create a Web page that manages a shared folder, which means you can upload and download files, these preferably pdf and a certain size. This shared folder has security therefore must be accessed in any way with user key.
I need to know if there is some sort or some method easy to perform in ASP C#, give me options to view folders and their files created and upload new in a new folder.
I would appreciate your help and advice in order to make this website.
Use System.IO.DirectoryInfo and System.IO.FileInfo to work with a file system from .NET.
Using 'System.IO.FileStream' in one way to create new files from binary data (stream or byte[])
Easy way would be to use a third party control like FileUltimate
Or you can bulid your own custom file manager by using utility classes in System.IO and HttpResponse class for file streaming

How to encrypt folder in Windows?

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.

How can I read an xml file from the users computer on an ASP.NET MVC2 site?

I am writing a website to consolidate a bunch of XML files with data into one MySQL database. I need to have a way to allow users to select a directory on their computer that contains a bunch of xml files. The site then reads each of those files and takes care of consolidating the information.
Is there a simple way (like the default open file dialog for win forms and wpf) to bring up a file dialog on a users computer, let the user pick a directory, and then be able to read the xml files in the selected directory? Would I have to upload them to the site temporarily first? Or could I just access them on the users computer?
Thanks!!
You can't access files from a webserver directly. You would need to write an ActiveX Control if you really don't find another way.
The standard conform way it just uploading one or more files with the browser fileupload:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.aspx
I would suggest that the user should zip the files and just upload the zip file.
There are some hacks - but I don't think it fits:
http://the-stickman.com/web-development/javascript/upload-multiple-files-with-a-single-file-element/
http://dotnetslackers.com/articles/aspnet/Upload_multiple_files_using_the_HtmlInputFile_control.aspx
I think you have to have a web dialog to upload the files to a temp location like you already mentioned and do the consolidation there before committing to your database. Or, maybe you can do the consolidation in JavaScript in the user's browser instance.

Categories