Page 1 of 1

Sending list file string back from server

Posted: Thu Jun 11, 2009 4:06 pm
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

Re: Sending list file string back from server

Posted: Thu Jun 11, 2009 5:29 pm
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]

Re: Sending list file string back from server

Posted: Fri Jun 12, 2009 7:52 pm
by cserold
Thank you very much. That solved my problem.