🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / C# RMOS / dosya uzantısı değiştirme

1-) C# RMOS - dosya uzantısı değiştirme

 

var result = Path.ChangeExtension("dosyanın tam yolu", ".jpg");

 

veya

 

File.Move("dosyanın eski yolu", Path.ChangeExtension("dosyanın yeni yolu", ".jpg"));

 

 

2-) sadece ismini değiştirme

 

 if (e.FullPath.Contains("SEAWORLD_"))//

     {

  string dir = Path.GetDirectoryName(e.FullPath);

  string ext = Path.GetExtension(e.FullPath);

  string path = Path.Combine(dir, "otels_" + DateTime.Now.ToString("dd-MM-yyyy__h-mm-ss") + ext);

    System.IO.File.Move(e.FullPath, path);}

 

veya

 

string path = @"photo\myFolder\image.jpg";

string file = Path.GetFileNameWithoutExtension(path);

string NewPath = path.Replace(file, file + "-resize");

Console.WriteLine(NewPath); //photo\myFolder\image-resize.jpg

 2021 Ocak 18 Pazartesi
 588