0

I am trying to find solution to this from last 2 hours, I have searched a lot on this but didn't found any solution(may be I am searching with wrong keywords), but the problem is I want remove file properties which contain special characters. Please check attached image for what I want to say.

I am using ASP.NET FileUpload control and C# as programming language. I want to make sure that any file uploaded does not contain any special characters in its properties.

enter image description here

Please help.

Thanks.

Nikhil Chavan
  • 1,685
  • 2
  • 20
  • 34
  • 1
    possible duplicate of [How to set and get values in Detail Properties of file? c#](http://stackoverflow.com/questions/17524646/how-to-set-and-get-values-in-detail-properties-of-file-c-sharp) – Jauch Jul 14 '15 at 09:24
  • Please post your actual code. Then, I think you can use the `System.IO.FileInfo` and `System.IO.FileAttributes` class to get file attributes and then `System.IO.File.SetAttributes()` to change them. – Cheshire Cat Jul 14 '15 at 09:25
  • Comments are stored in the JPG, see how to change metadata :=) – Laurent Lequenne Jul 14 '15 at 09:26
  • @Jauch - Thanks for sharing link to existing question. – Nikhil Chavan Jul 14 '15 at 09:32

1 Answers1

1

Have you tried looping through Image.PropertyItems?

You can modify the image to remove unwanted details via GetPropertyItem() and SetPropertyItem()

References: https://msdn.microsoft.com/en-us/library/system.drawing.image.propertyitems(v=vs.110).aspx

https://msdn.microsoft.com/en-us/library/system.drawing.image.setpropertyitem(v=vs.110).aspx

https://msdn.microsoft.com/en-us/library/system.drawing.image.getpropertyitem.aspx

Sample here in StackOveflow: Value of image property (C#)

Community
  • 1
  • 1
Joel Legaspi Enriquez
  • 1,236
  • 1
  • 10
  • 14