I'm working on a project and I need to create a hash for and image and I did it, with the image propertyItems, but if I copy paste the image I get the same hash, I thought on get the hash based on the creation and last modified date.
I did some research and I found that I get use File.GetCreationTime(#"C:\Users\image.png");
and File.GetLastWriteTime(#"C:\Users\image.png"); but that implies that i have a path to the files, and my file is being download from a blob storage, is there any better way to do it? instead of needing to downloading and saving every image in a folder to get the path.
Sorry for my bad english :)
Related
I am saving PNG images and would like each individual image to have its own version number.
I was originally doing this in C# and saving every PNG file and adding on ?v=54165 which gives the file its own unique number while keeping it as a png, so for example the whole file would look like this:
imagename.png?v=67485
The problem is that in Windows you cannot save an image with a question mark in the filename as it is a reserved character. I would be grateful if someone could provide an alternative?
EDIT: I need the number to be after the file extension.
Sorry, it is not possible in Windows to add any information after extension in filename. It is better to save image as
'imagename__v67485.png' to avoid complexity in filename
I have a program in c# that downloads images from a web service.
The download usually takes time so I want to save the images locally so I would only need to download each image once. The problem with that is when the images saves the user of the program can see the image in the files and change it.
Is there a way to save the image in the program, yet keep it from users to see and change in the folder?
EDIT: solution used:
Encrypting the images and their names when I save them, and only access them this way. (decrypting when after reading them).
What is your intent? Anything your program has access to do, your user does as well. If you're just trying to prevent people from accidentally mucking with your images, then save off a SHA1 or similar hash of the file and store it separately. When you need an image, check the SHA1 and redownload if it doesn't match. This will prevent casual tampering, but still isn't 100% effective against malicious changes.
I'm developping an application with C# that create an ISO image from a CD/DVD, then it lets the user to delete files contained in the Iso file, but so far I didn't find a way to do it.
Please if you have any idea.
Thanks in advance
You should just change the order in which your program operates. Read in the file hierarchy first, then allow the user to select which files to delete, and then write the remaining out as an ISO file. You should be able to keep the files and directories in a tree data structure. Deleting a folder or file would just delete a corresponding node or leaf.
As to the question of directly deleting a file or directory in an ISO image, the same rules above apply, as the ISO9660 (ECMA-119) format is essentially a serialized tree structure. Simply zero out the corresponding records for the subtrees and leafs you want to delete. Do note however, that such an approach will leave garbage space in the image. And that to actually get the image to be smaller in size, you would need to do a compression operation on the image (re-serialize the hierarchy out to a new 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.
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).