Change File Extension Using C#

后端 未结 5 1468
北荒
北荒 2020-11-29 06:34

I have many file types: pdf, tiff, jpeg, bmp. etc. My question is how can I change file extension? I tried this:

my file= c:/my documents/my images/cars/a.jp         


        
5条回答
  •  爱一瞬间的悲伤
    2020-11-29 06:54

    The method GetFileNameWithoutExtension, as the name implies, does not return the extension on the file. In your case, it would only return "a". You want to append your ".Jpeg" to that result. However, at a different level, this seems strange, as image files have different metadata and cannot be converted so easily.

提交回复
热议问题