Pergunta

I'm working on module which displays repository content on a web page, using SharpSvn (C#). In order the get the list of the url's content I'm using:

(client.GetList(new Uri(url), out contents);
foreach (SvnListEventArgs item in contents)
{
    //...Iterates...
}

So for each item I get the information about name, path, url... But I also need to know it's size. So is there any way to get this information from the svn server, using SharpSvn?

Thanks.

EDIT: DJ KRAZE's answer made me realize my question wasn't clear enough. The product is a Dropbx-like website, where all the svn (authorized) users can see and browse the repository on the web. So this code should run on the svn server. For example - a user adds files from it's own PC (with tortoise, e.g), and commit. Later he wants to see these files on the web (again, just like dropbox), along with their sizes. Does sharpsvn provides this functionality?

Foi útil?

Solução 3

Subversion doesn't offer a way to get the file size. The only way to do this would be to run Export and check the file size, but that would be rather expensive for a dir listing..

Outras dicas

it is possible to retrieve file size in svn, because tortoise SVN able to list file's size in repo browser. Here is the C# code to do so:

//tested on SharpSVN 1.8009.3299.43
SvnListArgs arg = new SvnListArgs();
arg.Revision = new SvnRevision(2); //the revision you want to check
arg.RetrieveEntries = SvnDirEntryItems.Size;

client.GetList(target, arg, out list);
long sizeInBytes = list[0].Entry.FileSize;

Shay__ who are you going to use the file paths after you get them..?

using System.IO;


(client.GetList(new Uri(url), out contents);
foreach (SvnListEventArgs item in contents)
{
    //FileInfo object and get the Length.
  FileInfo fi = new FileInfo(item);
  long fileLength = fi.Length;
      .....
    //once done with what you want Null the FileInfo Object
    fi = Null;
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top