I'am working on my small project: Crypt container. To unlock it - just plug-in specifig usb flash-drive and unplug it to lock container.
So, GUI of program is very simple - just ListView. If you want to add files into continer - drag'n'drop items to them.
But i have a problem - when user want to decrypt his file, he drag them in container and drop to desktop (or specific folder). And my task is to know, where user wants to put a file. If he drag file to folder - i should unpack it to folder, if he drag it to flash-drive - i should unpuck it to flash-drive.
Yes, i found one solution of my problem: http://www.codeproject.com/KB/files/DragNDrop.aspx , but i realy not understand that mechanism with tempDirectoryWatcher and Hashtables.
Maybe somebody know easy way to get path to object (folder, drive, etc.) under cursor?
Your data object should expose FILEGROUPDESCRIPTOR and FILECONTENTS. The user might drop onto something other than a folder, like an email message, or into a virtual folder like an FTP site or a ZIP folder
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'm a little stuck, as for this moment i don't have any code only an idea.
I was thinking to make a program in asp.net to list files within a location.
The file will probably be releases for programs and mods for gaming and stuff.
But i have searched everywhere to get files in a location. I could use system.io.fileinfo to list files in a directory.
But how to I get a Directory not in the solution but somehwere on the hard drive or even external storage server? The location i prefer not to be hard coded but selected by the user? any toughts on how a user can select a 'location' ?
In a console application, you could be doing something like this :
Ask for the path from the user with a readline.
Check if the path is correct / exists. (if not you could create it or display an error, also it could be a path with a file, you need to check if the path is to a directory or to a file)
Do the display of the files inside of the directory as intended.
We need more precisions if you want a better answer.
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.
I want to transfer a file to an Android device using a USB cable and file explorer, and then access it in my Xamarin.Forms app.
As far as I understand there are two ways to do this (and please correct me if I'm wrong):
Since it's an image file - Just put it anywhere and let some
background task find it and add it to what seems to be a virtual
folder of Images. And then access it there.
A more general solution - browse to that specific folder.
Both solutions rely on using FileInfos etc. but unfortunately the folder structure is much different than I see using windows explorer - instead of Alarms, Android, etc. which I see on windows explorer - is see cache, config, etc. using C#, and access to some like data is not allowed (I get an exception). I also tried finding information on how I would search for all images on the device, but either it's not as simple as I thought it would be, or I'm using the wrong keywords.
The file will be put there by a user, so it cannot be added to the project's resources.
Xamarin has a nice way to navigate the files in android, using Android.OS.Environment.ExternalStorageDirectory.Pathwhich you can concatenate with your directory/filename so you can save/access data.
If you want to open the android dialog box so the user can find a file in its device, you can take a look at: https://developer.xamarin.com/recipes/android/data/files/selecting_a_gallery_image/
Remembering that you need to add the READ_EXTERNAL_STORAGE permission to your android manifest file and check runtime permissions. Runtime permissions can be easily checked with https://github.com/jamesmontemagno/PermissionsPlugin
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