简体   繁体   English

如何添加文件扩展名而不删除旧扩展名

[英]how to add file extensions and not delete old extensions

I have the desire to add file extensions and not change the old extension. 我希望添加文件扩展名而不更改旧扩展名。 Suppose file.jpg becomes file.jpg.bmp is that possible ? 假设file.jpg变成file.jpg.bmp可能吗?

string filename;
                string[] file = Directory.GetFiles(folder_path);
                foreach (string myfile in file)
                {
                    filename = Path.ChangeExtension(myfile, ".bmp");
                    System.IO.File.Move(myfile, filename);
                }

my code only changes extensions, for example file.jpg becomes a file .bmp 我的代码只更改扩展名,例如file.jpg变成文件.bmp

I want to be file.jpg.bmp 我想成为file.jpg.bmp

Please help thanks 请帮忙谢谢

Try something like that: 尝试这样的事情:

string[] file = Directory.GetFiles(folder_path);
foreach (string myfile in file)
{
      System.IO.File.Move(myfile, myfile + ".bmp");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM