0
我試圖以編程方式建立文件夾中的文件列表,具有文件大小和修改日期等特定屬性。asp.net System.IO.IOException
我可以返回文件名,但任何其他屬性都會引發錯誤:System.IO.IOException:文件名,目錄名或卷標語法不正確。
我在這裏錯過了什麼?
private void BuildDocList()
{
var files = Directory.GetFiles(Server.MapPath(FilePath));
foreach (var f in files)
{
var file = new FileInfo(FilePath + f);
var fileItem = new ListItem();
// this line works fine
fileItem.Text = file.Name.Split('.')[0] + ", ";
// this line causes the runtime error
fileItem.Text = file.CreationTime.ToShortDateString();
FileList.Items.Add(fileItem);
}
}
這樣做了,謝謝! =) – shimonyk 2009-10-31 14:53:15