Sending list file string back from server

Explorer-like frontend add-on to upload/download.
Post Reply
cserold
Posts: 7
Joined: Thu Jun 11, 2009 4:00 pm

Sending list file string back from server

Post by cserold »

Hello,

I can't figure out the correct way to delimit the fields (type, filename, last modified, and size) in my string being returned from an ASP.NET handler page. I am using the following code but my remote directory structure is displaying as shown in the attachment.

Code: Select all

	private string GetFileString(string rootPath)
	{
		StringBuilder sb = new StringBuilder();

		DirectoryInfo di = new DirectoryInfo(rootPath);

		sb.Append("<pre>");

		if (di.Exists)
		{
			foreach (FileSystemInfo fsi in di.GetFileSystemInfos())
			{
				sb.Append((fsi.Attributes == FileAttributes.Directory ? "dir " : "file ")).Append(" ");
				sb.Append(fsi.LastWriteTime.ToLongTimeString()).Append(" ");
				sb.Append((fsi.Attributes == FileAttributes.Directory ? "" : (((FileInfo)fsi).Length / 1024).ToString()) + " KB").Append(" ");
				sb.Append(fsi.Name).Append("<br>");
			}
		}

		sb.Append("</pre>");

		return sb.ToString();
	}
I appreciate the help!

Craig
Attachments
jfileexplorer.jpg
(155.32 KiB) Downloaded 209 times

User avatar
support
Posts: 1503
Joined: Sun Jan 27, 2008 6:19 pm

Re: Sending list file string back from server

Post by support »

Here is a sample of what is expected:

Code: Select all

<pre>
file 1231079974698 5345408 Don't Stop The Music.mp3<br>
file 1233491390608 4268160 Shut Up and Drive.mp3<br>
file 1234210795183 540756 344IMG_0092 CC.jpg<br>
dir 1233485383837 4096 remotefolder<br>
file 1233684915298 3275 requestProcess.html<br>
</pre>
Each line must end with [\r][\n]

cserold
Posts: 7
Joined: Thu Jun 11, 2009 4:00 pm

Re: Sending list file string back from server

Post by cserold »

Thank you very much. That solved my problem.

Post Reply