Images from common project - c#

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

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.

What is best way to use image files in my project in C#

I'd like to easy change image files in my program and have access to their names and amount of them. What method do you suggest? Should i read images as array from folder or better make resource file with them?
If you are making a map editor, then I imagine you will have lots of small images to handle in which case it may be a good idea to store them in some form of resource file, although you may have more flexibility to change them if you store them externally in a folder.
Once the images are loaded in, I would imagine you will want to store them in some form of hierarchical structure if its for a map editor too, associated to the object of which they represent.
If you plan to do any processing on large images, investigate using Bitmap.LockBits() as this will be much more efficient.
http://msdn.microsoft.com/en-us/library/5ey6h79d.aspx
Using resources: Load image from resources area of project in C#
Loading images from file: http://msdn.microsoft.com/en-us/library/4sahykhd.aspx

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.

Creating File On Full Disk

Is it possible to create a file on a disk which is full??
Does creation of the file take any space??
Basically I am seeing a case where C# has created but failed to write anything whhich I think points to a full disk.
Does anyone know whether creating a file on a full disk will fail or not??
This wa done using c# o Windw xSerevr- The log file was also written to the same drive
Creating (empty) files should still be possible in most cases. The MFT is a separate part of the volume which won't get used for file data.
It should even be possible to store small amounts of data without needing more than the file entry in the MFT. NTFS can store streams as "resident data" in the stream descriptor which doesn't need any additional space, but only works for very small files.
I think your issue is another problem, though. It may be that you have permissions to create a file but not to write anything to it. You might want to check the ACLs of the location where you're trying to write.

Categories

Resources