Skip to content

Instantly share code, notes, and snippets.

@PatrickRainer
Created October 3, 2023 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatrickRainer/160d6016619ee0a4282a19b586a55921 to your computer and use it in GitHub Desktop.
Save PatrickRainer/160d6016619ee0a4282a19b586a55921 to your computer and use it in GitHub Desktop.
public class FilePath
{
public FilePath(string fullPath)
{
FullPath = fullPath;
}
public string FullPath { get; }
public string FileName => Path.GetFileName(FullPath);
public string FileNameWithOutExtension => Path.GetFileNameWithoutExtension(FullPath);
public string Extension => Path.GetExtension(FullPath);
public override string ToString()
{
if (FullPath.Length <= 11) return FullPath;
if (FullPath.Length == 0) return "";
var fileName = Path.GetFileName(FullPath);
return @$"...\{fileName}";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment