Change File Extension Using C#

后端 未结 5 1464
北荒
北荒 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:56

    try this.

    filename = Path.ChangeExtension(".blah") 
    

    in you Case:

    myfile= c:/my documents/my images/cars/a.jpg;
    string extension = Path.GetExtension(myffile);
    filename = Path.ChangeExtension(myfile,".blah") 
    

    You should look this post too:

    http://msdn.microsoft.com/en-us/library/system.io.path.changeextension.aspx

提交回复
热议问题