Closed GoogleCodeExporter closed 9 years ago
Yes, I reproduce this error also and it exactly throws:
FormatException (Could not find any recognizable digits.)
And this is the solution:
In TarHeaders.cs everywhere you find
'Convert.ToInt32(Encoding.ASCII.GetString(buffer, x, x), 8);'
add Trim() function like 'Convert.ToInt32(Encoding.ASCII.GetString(buffer, 100,
7).Trim(), 8);'
Original comment by pih...@gmail.com
on 8 Dec 2009 at 8:16
Get the latest version from SVN. It should be fine.
Original comment by vasilt...@gmail.com
on 17 Jun 2011 at 8:25
It's not fixed everywhere:
See line 123 and 125 in TarHeader.cs. I just ran into that.
https://code.google.com/p/tar-cs/source/browse/tar-cs/TarHeader.cs#123
https://code.google.com/p/tar-cs/source/browse/tar-cs/TarHeader.cs#125
Original comment by thefunkw...@gmail.com
on 7 Aug 2014 at 3:17
Additionally, .Trim() is not working in C# to get the "\0" removed.
See also
http://stackoverflow.com/questions/3387733/how-to-remove-0-from-a-string-in-c
Instead of .Trim(), use .Trim().Replace("\0","") everywhere.
Example:
Mode = Convert.ToInt32(Encoding.ASCII.GetString(buffer, 100,
7).Replace("\0",""), 8);
Or move that line of code in a dedicated method:
private string TrimNulls(string input)
{
return input.Trim().Replace("\0", "");
}
public virtual bool UpdateHeaderFromBytes()
{
FileName = Encoding.ASCII.GetString(buffer, 0, 100);
Mode = Convert.ToInt32(TrimNulls(Encoding.ASCII.GetString(buffer, 100, 7)), 8);
...
Original comment by thefunkw...@gmail.com
on 14 Aug 2014 at 12:29
Original issue reported on code.google.com by
jure.mi...@gmail.com
on 28 Oct 2009 at 11:27