Optimal way to output a dictionary
One way to speed up the lookups is to use TryGetValue() instead of ContainsKey() and then the indexer. So, for example:

if (hashs1[i].ContainsKey(filenamef))
{
    sw.Write(hashs1[i][filenamef]);
}


would become:

string value;
if (hashs1[i].TryGetValue(filenamef, out value))
{
    sw.Write(value);
}


But it's hard to tell how much would that help you.

Another thing that might help you would be combining all the hashes into one that contains object that contains all the inner hashes. Something like:

class Hashes // or struct?
{
    public Dictionary&lt;string, string&gt; hash1 { get; set; }
    public Dictionary&lt;string, string&gt; hash2 { get; set; }
    public Dictionary&lt;string, string&gt; hash3 { get; set; }
    public Dictionary&lt;string, string&gt; hash4 { get; set; }
}

…

var mainHash = new Dictionary&lt;int, Hashes&gt;(f.Count + 2);


Combining the two approaches lowers the number of potential lookups per iteration from 16 to 5.

Also, unrelated to performance, but you should name your variables by their contents, not implementation. I think hash1 is a very bad name.