I am learning c# and making my first UWP app with it. Bit stuck on a folder/file permission problem. The app I am making is a file renaming app where i want the user to drag and drop a bunch of files and folders onto a <ListView/>, the <ListView/> will scan the dropped items and display the filenames, then the app is supposed to loop over the files one by one and rename them according to whatever options the user selects.
However, the app does not have permissions to the dropped files. The only way (as far as my research has led me to believe) to allow the app to modify the file names is by using a File Picker and allowing the user to select the files he wants to rename manually thereby granting permissions to modify them. This is a potential solution to my problem but it means that i cannot use the drag and drop functionality that i think is a much more elegant solution.
So my question is whether there is a way to grant permission to the files and folders the user drops onto the <ListView/>
I'm afraid there's not much you can do about the given read-only permission. Except for maybe leaving your voice on uservoice.
Related
I'm writing an application that amongst other things will have to import some files. The user points to the main file with a picker which grants access to that file. However, there are additional files refrenced within the file. How do I gracefully access them?
To illustrate situation better:
manifest.xml
media (folder)
image1.jpg
image2.jpg
image3.jpg
User picks manifest.xml which mentions media files. I'd like to programmatically access them.
I realize I could declare broadFileSystemAccess capability, but from what I gather, it still wouldn't work in certain locations. For example if imported files were placed in C:. I would also have to explain myself when submitting application.
Embedding additional files is not possible because I have to work with over 20 years old standard which doesn't support it.
So it seems that the only way to do this without broadFileSystemAccess (which is not cure for everything) is to use FolderPicker and ask for folder containing file to be imported. From what I tested, it grants you access to picked folder and all its subfolders and files.
However, this solution is not perfect. FolderPicker is unable to display files in its dialog (just the folders) so you have to know where the file you want to import is beforehand. Then, after folder is picked, you have to test if it really contains file that can be imported and take into consideration, there might be more than one. It means, you'll have to create another dialog of your own which will ask user which file he wants to import. You might even want to do that with one file just to make sure the user knows what he's doing.
I am working on a Windows 8.1/10-based Kiosk-type product (closed-down, no Windows GUI). We have our own user management system where every user of the Kiosk has to log on. Windows-wise the user is always the same auto logged on one, for reasons beyond my control.
In the process after logging on, files will be created. As the Windows user is always one and the same, the owner of created files will always be the same. How would I go about applying some kind of user context/ownership indication to the created files using our own user context? The most important use of this would be to keep track of which files to show/list for which user. We use C++ and C#.
edit: This has not been a problem until now, as each user has had their files stored in their own directory. We have then used that fact for deciding what files to show to a user. We are now changing that to instead let certain input dictate where the files are to be created for a more flexible, custom file structure.
I've been trying to learn how to handle saving normal .txt files in UWP, and have realized that it's quite locked down compared to WPF, especially in the sense of what folders you can access without requesting the user to select a location. I have searched for various ways this might be possible but found no working answer.
Question Description:
I basically would love to know if this is possible, and preferably a point in the direction where I can learn how exactly to do this.
Application settings page requires user to select folder where files are saved.
Application remembers this between launches (unsure if this is possible, but I can't require the user to select the folder on every launch)
Application saves files to the specified folder.
In my understanding, this should be possible, as the user is the one specifying the location via filepicker, but is it possible to have this work between launches so that the user wont be required to re-select the save folder?
I need to figure this out, as I would like my application to support selecting attached network drives, cloud storage folders, etc.
Any help is very much appreciated, and if there are any questions I will answer them to the best of my ability.
Fow this purpose there are two access lists designed: FutureAccessList and MostRecentlyUsedList. Once the user has picked up the folder with the picker, you add it to such list and receive a token, which you save for future purpose in LocalSettings:
ApplicationData.Current.LocalSettings.Values["MyFolder"] = StorageApplicationPermissions.FutureAccessList.Add(pickedFolder);
Then later, once you want to access that folder, you can do it like this:
StorageFolder folder = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync(ApplicationData.Current.LocalSettings.Values["MyFolder"].ToString());
You can't save a StorageFolder or a path to it in settings, hence the UWP app needs permissions to access the folder. Using above access lists solves this problem.
I believe you want to save user settings and keep it somewhere so that next time when they launch the application, they can use the same settings.
Please check out this tutorial from Microsoft, which describes how to do exactly that.
https://msdn.microsoft.com/en-us/library/bb397750(v=vs.110).aspx
I would like to create a c# application which will open when i open a folder automatically.
My c# application is intended to be like a password system, so that the contents in the folder can only viewed after logging in to my application. Everything is ready..........
but i am confused how to open my application directly while opening the folder with a c# script?
I have now created a application which will ask the user for name and password while opening the application and now i want to make it open through the folder to be locked , how to do it?
Ok, first of all if you want the folder to be secure you should encrypt it otherwise all the user has to do to gain access is kill the process.
What i would recommend you do instead is create a encrypted file. For example a zip file. Then all you have to do associate the file with the program and to unpack it with the password. Then when the user is done delete it and overwrite the temporary folder. It's really important that you overwrite it otherwise the encryption is useless.
If you want to avoid conflict with other programs that work with zip files you can make your own file type it does not affect the content of the file in any way.
I hope this helps.
To make sure I understand... you want to build an application that will, when someone tries to open it, will only open after they supply a password. Hmmm... okay. A specific folder, or any folder? Local folders or folders on network shares? I initially was thinking a file system watcher approach, but that will only work on change events, like copying, renaming, deleting, etc. So that won't work. The closest would be to check last accessed time, but that is an alert ex post facto, so this must be rejected. I'm not sure how you could do this in C#. What is wrong with the robust security options MS has already established, like global groups. That provides flexible restrictions on access. Especially over large amounts of folders. Are users going to have one password per folder? Too cumbersome. One password per user? Use Windows authentication to lock it down. How is this app storing the passwords?
I recommend trying to leverage existing technology to solve problems before trying to re-invent the wheel. You have omitted the scope of this, and what you have already attempted, so we may not understand completely.
I know this isn't a strait up code question, but I'm trying make a program that could possible be running in the background of my computer, and allow me to leave my files/folders where they are, and upon double clicking on a file/folder a dialog box comes up asking for a password. All these programs that are on the market require you to move files around, create new volumes; I don't want that, I want simplicity. One dialog box with password promt, then file/folder opens. My question is what do I need to look into coding wise to make this possible? Thanks for any advice/tips. :)
FileSecurity()
Also Is this something that can only be done with NTFS and not FAT?
You can not detect when someone click or double click a folder, so no, it is not possible.
you can use FileSystemWatcher to detect when a file is opened and handle the open event, but unfortunately you cannot prevent its execution
I can think of only three ways how to SECURELY protect file:
write filesystem driver (similar used by antivirus software for example), but isn't not possible in C#
encrypt all files when user locks folder and decrypt them back when user unlocks folder.
for non-admin accounts, you can set privileges (and on NTFS also built-in file encryption) in such a way, that without admin password user can't access them
Method used in article you mentioned is not secure at all (any user can just rename the folder back to get access to protected files). Though you can use the same trick to run you program automatically when user double-clicks protected folder and unlock files if user enter correct password.