November 6, 2013

Path Extension Class

This helper creates a temporary file with the given extension.
public static class PathExtensions
{
 // Create a temporary file with a specific file extension
 public static string GetTempFileName(string extension)
 {
  string tempFileName = Path.GetTempFileName();
  string newtempFileName = tempFileName.Replace(".tmp", extension);
  File.Move(tempFileName, newtempFileName);
  return newtempFileName;
 }
}

No comments: