andrew4582

ChangeFileName

Feb 20th, 2013
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.42 KB | None | 0 0
  1.         public static string ChangeFileName(string path, string name)
  2.         {
  3.             string directoryName = Path.GetDirectoryName(path);
  4.             string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path);
  5.             string extension = Path.GetExtension(path);
  6.  
  7.             string nameWExtension = string.Format("{0}.{1}", name, extension.Trim('.'));
  8.  
  9.             string fullPath = Path.Combine(directoryName, nameWExtension);
  10.             return fullPath;
  11.         }
Advertisement
Add Comment
Please, Sign In to add comment