Automatically add and delete images in WP7 app storage - c#

I want to make a "recent pages" section in my WP7 app which will show thumbnails of 6 recent browsed pages. How to make a method which saves only 6 image files in the storage and when new ones come replace old ones with it?

Assuming that you define "new" based on the date/time that the image file in IsolatedStorage was created you could determine this by querying GetCreationTime on the file.
You can use IsolatedStorageFile.GetFileNames to determine how many / which files exist. Note: you probably want to create these files in a specific folder so you don't have to worry about other files in IsolatedStorage.

Related

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

ASP.Net MVC store within Resource or as Content

I have a very huge amount of images (about 20K) that I don't want to be directly accessible by a user. Therefore I have a controller that streams a requested images back if the requesttoken is valid. I wonder now if I should store the images within a internal Resourcefile or just as content? I tried content before but you are able to access them from the browser if you know the folder and filename. The files don't change at runtime.
Thanks in advance for any hint on this!
You should use the App_Data folder for this. This folder is hidden from the outside so it is ideal for storing embedded databases or files as you want.
You may be interested in:
What is the App_Data folder used for in Visual Studio?

Images from common project

I have 4 projects in same solution. In one project the images get uploaded & stored in some folder.Now I want to show this image in another project which is in same solution.What code should I write in C#?
It seems to me that it would be sensible that the same project responsible for storing the images should be responsible for retrieving them too... either by providing a filename "mapping" service (e.g. original upload filename mapped to physical location on disc) or by giving a method which will open the file and return a Stream to the data. Then showing the image becomes a matter of calling that method and then loading the image as normal.
It's hard to be more precise without more details of what you're trying to do, how the image is stored etc. What have you already tried, and what problems have you run into?
You can keep the ImageFolder path in config file in all the project.
And that path can be use to Read/Write the image(s).

Displaying images in a list box keeps files locked

I have a list box of images which I am adding programatically from my my pictures directory. I want to be able to put images in the directory and the UI displays it automatically. I also want to be able to remove photos from the directory and have the UI update as well but the problem is that the images are being used by the application so I am not able to remove the images from the directory. Is there a way to unlock the files so I can rename and remove files from the directory?
Are you using data binding like Image Source = {Binding FilePath} ? If so, you need to load the image with CacheOption = BitmapCacheOption.OnLoad, you can do it declaratively with a ValueConverter, like this one:
http://soulsolutions.com.au/wpf-reference-an-image-without-a-file-lock/
Do you load images with Image.FromFile? I've noticed this behavior a long time ago. Try opening the files with File.Open, loading the images with Image.FromStream, then close the stream.

Categories

Resources