Timestamp when file last modified in C#
The conversion of the code isn't that easy because of two key differences between PHP and ASP.NET:


.NET doesn't do Unix timestamps, so you'll have to introduce a conversion from DateTime to timestamp.
ASP.NET doesn't set the current directory to your application's directory, so relative paths aren't going to point to files existing in your web application.


So all code you have there is relevant. Not shorter, but more readable and less repetitive is the following:

using System.IO;

public static string AssetTimestamp(string filename)
{
    string filePath = HttpContext.Current.Server.MapPath(filename);
    string absoluteUri = System.Web.VirtualPathUtility.ToAbsolute(filename);

    if (!File.Exists(filePath))
    {
        return absoluteUri;
    }

    DateTime dt = File.GetLastWriteTimeUtc(filePath);
    int unixTimestamp = (int)(dt.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
    return absoluteUri + "?" + unixTimestamp;   
}