ASP.Net MVC store within Resource or as Content - c#

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?

Related

How to cache web to read offline in webcontrol window phone

I'm using to load website follow code
webContent.Navigate(new Uri(linkURL));
I want to cache all content and html tag, style, js in web to read offline.
I tried download html source, file css and js using Webclient and replace these file to html resource then save to file "index.htm" but not good.
Can you find the way to resolve this issue? thank you.
The only way to do this is to download ALL the relevant files (including those referenced inside the HTML. eg. images, css, js, etc.) and save them ALL to Isolated Storage with appropriate similar file and folder structures.
The important point is that you also need to update all the paths within the content so that they point to relative paths that match where files have been saved.
You can then load the HTML from IsolatedStorage.
This is potentially a lot of work. I'd recommend exploring other options if possible first. Also remember to manage the files stored in IsolatedStorage appropriately so you don't just keep adding files there indefinitely.

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.

Automatically add and delete images in WP7 app storage

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.

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).

Categories

Resources