Saving out multiple files in Windows Store - c#

I have a windows store app that uses an internal file library hosted in localstorage. Is there anyway to export these en masse without needing to make the user choose a location / file name for each file?
I know I can zip them up and export the zip, but I was hoping to allow the user to choose a folder and then save a series of text files into that folder. Is this possible?
I'm not looking for someone to write my code for me, just point me in the right direction

Get the files in a List (from LocalStorage)
run a foreach loop (for the List<Files>)
let user choose the location once (in phone memory or m/m card)
and then simply copy all files in the same location one by one through the foreach loop (because you have the StorageFolder, you can use StorageFile's CopyAsync method)
I've done this in my WP store App (kind of File Explorer).
Hope this helps..!

Related

Save File and Protect from User Writes

I would like users to add files to a program, in a Windows Active Directory Environment. I would then like the program to save the files to a directory. However I would like to have the files saved to a directory where the user only has read access. Once the file is saved it is permanent and cannot be edited by the user, but they can still open it and save it locally with changes if desired.
This would be like saving the file with elevated permissions.
I don't think setting a read only attribute will do the trick as to my knowledge if the user finds the directory and file they could change that status manually. I also don't think System.IO.File has this kind of functionality.
Is there anyway to achieve this?
It seems FileIOPermission library could solve this porblem so use c# sharp libary which is "FileIOPermission", you can go over from this.

C#, How to Traverse all drive and folder to copy image and paste them in a specific folder?

my project was a image gallery using asp.net.
Initially when then the project load first time i need to copy all the images in the computer and paste them in a folder named Data.
here is my project link:
https://www.dropbox.com/s/sr3qhaamiiwk0di/Gallary_temp.zip?dl=0
https://drive.google.com/file/d/0BynGaI0gi3mrOEtweWlWOEdmSFE/view?usp=sharing
Of course, code must be in c#
Instead of copying the image from hard drive to your location every time, it is better you save the file location in DB and call them when ever you require.

How to encrypt folders and files for a wpf application

I'm working on a WPF project which is in charge to display a picture library.
The pictures are stored on folders.
I would like to know if there is a way to encrypt the folders and the pictures to protect the files (the user shouldn't see the files), but I want to keep the possibility to browse these folders by code to build my library.
The best way that I can think of is to store the files and folders in a Zip archive with a password. Zip files are supported natively by Windows. There are plenty of options for supporting zip files, including framework options and outboard libraries.
Note that this doesn't really protect the files from user tampering; it merely hides them from casual observers. Also, there may be a speed penalty; you should use the fastest possible options for compression.
you can use Zip archive and Another way:
you can add another project project(Library)into your main solution,add your image folders into your application and set their build action property to resource,with that,your images will store in an Dll and for can access them from Dll.i tried it before follow this link:
get-folder-address-in-dll

Best way to store a file temporarily untill the usage of file

As we all know that we can not get the full path of the file using File Upload control, we will follow the process for saving the file in to our application by creating a folder and by getting that folder path as follows
Server.MapPath
But i am having a scenario to select 1200 excel files, not at a time. I will select each and every excel file and read the requied content from that excel and saving the information to Database. While doing this i am saving the files to the Application Folder by creating a folder Excel. As i am having 1200 files all these files will be saved in to this folder after each and every run.
Is it the correct method to follow or not I don't know
I am looking for an alternative solution rather than saving the file to folder. I would like to save the full path of file temporarily until the process was executed.
So can any tell me the best way as per my requirement.
Grrbrr404 is correct. You can perfectly take the byte [] from the FileUpload.PostedFile and save it to the database directly without using the intermediate folder. You could store the file name with extension on a separate column so you know how to stream it later, in case you need to.
The debate of whether it's good or bad to store these things on the database itself or on the filesystem is very heated. I don't think either approach is best over the other; you'll have to look at your resources and your particular situation and make the appropriate decision. Search for "Store images on database or filesystem" in here or Google and you'll see what I mean.
See this one, for example.

File transactions issue - storing where each file come from?

I am creating an application that uses Quartz.NET to automatically download and upload files to various sources (HTTP, FTP and Network paths) based upon a regular exprsesion. Users can select multiple paths for each download and upload operation, so a typical job may be to download files from a http server, and also download from an ftp server, and upload all files to a network path.
Currently, I am downloading all files from all the download sources, and storing them in a folder (With the name of a folder being a GUID specific to that job). Then for the upload stage, it will simply read all files from that directory, and upload them to the path, which is great.
Problem is, for specific paths, the user may request these to be deleted after upload has completed, which is an issue as how can I find out where a file come from in a folder? I've been trying to think of ways around this, such as creating folders for each download path, but I'd need to check for duplicate names on download rather than upload, plus I'd need to merge both subfolders...etc!
Can anyone offer any ideas? Many thanks
Think about this in a object oriented manner.
Create a class like this
public class File
{
public string source;
public string destination;
public bool deleteSource; //if true delete the source after the copy
}
Now create a list of File classes like List<File> files and keep that as variable in your app.
Add objects to the list in the start and then traverse the list and copy / upload files. Check the deleteSource property and if it is true delete the file after the copy operation.
This is a basic idea and expand this class as required.
What I want to stress is that think of a problem in the object oriented way and start designing
When you download a file, can you create a separate text file that contains the source and destination paths? That way you can read in that mapping later and process them as necessary based on the source.

Categories

Resources